内核线程创建
来源:互联网 发布:制作电子报刊的软件 编辑:程序博客网 时间:2024/06/03 14:52
static int test_func (){
int i = 0;
while (1){
printk(" teset_func\n");
for(i=0;i++;i<20){
printk(" teset_func entry\n");
msleep(15000);
}
printk(" test func 2 \n");
}
return 0;
}
static int create_thread (void) {
struct task_struct *p =NULL;
int rc = 0;
p = kthread_create(test_func,NULL,"test_func");
if (IS_ERR(p))
{
rc = PTR_ERR(p);
printk(" error %d create thread_name thread", rc);
}
kthread_bind(p,1); //这里是绑定CPU1上哦,
wake_up_process(p); //这里需要wakeup ,线程才开始执行
return 0;
}
绑定好了后怎么查看工作是否生效了呢? 可以命令
taskset -c -p <pid>
$ taskset -c -p 332
pid 5357's current affinity list: 2 //这里2就是CPU1, 对应1就是CPU0
还有一种简单的创建方法,下面这种方法不需要wakeup就直接运行,所以就无法绑定到某个CPU了
static int create_thread (void) {
struct task_struct *p =NULL;
int rc = 0;
p = kthread_run(test_func,NULL,"test_func");
if (IS_ERR(p))
{
rc = PTR_ERR(p);
printk(" error %d create thread_name thread", rc);
}
return 0;
}
- 创建内核线程
- kthread_run 创建内核线程
- linux 内核线程创建
- linux内核线程 [创建]
- linux内核创建线程
- Linux 内核线程创建
- 内核线程创建
- linux 创建内核线程
- 内核线程创建
- uclinux内核线程的创建
- 内核线程创建与销毁
- linux内核线程的创建
- Linux内核中创建线程
- 内核笔记:内核线程的创建
- 进程.线程,内核线程创建的区别
- Linux 内核线程 的 创建 和 终止
- 内核线程创建: kthread_create vs kernel_thread
- linux内核线程创建销毁机制
- AE#GP之缓冲区
- MySql-You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v
- DelayQueue小例子
- 排序总结
- SQL语句嵌套查询问题
- 内核线程创建
- 查看DLL导出函数的方法
- 监听页面 F5 ctrl+R 事件
- SQL Server DBA调优---大数据量查询记录数优化及原理探讨
- android高级控件-Fragment
- 树上的动态规划
- Fragment+viewPager
- js,css加时间戳
- Another reason for Xtrabackup error “log block numbers mismatch”