创建内核线程

来源:百度文库 编辑:神马文学网 时间:2024/04/29 08:59:20
创建内核线程
2009-01-17 16:41:47

 /* 做为创建一个线程后的返回值 */
 volatile struct task_struct *thread;

 /* 创建一个内核线程,在加入网络成功之后testRfd一直在后台运行 */
 thread = kthread_create(thread_rfd,NULL,"rfd");
 /* 判断线程是否创建成功用 IS_ERR 不要判断thread是否为空 */
 if(IS_ERR(thread))
  printk("thread created failed!\n");
 else
 {
  printk("thread created success!\n");
  /* 创建成功之后随即唤醒 */
  wake_up_process(thread);
 }