kthread_create与kernel_thread的区别

kernel thread可以用kernel_thread创建,但是在执行函数里面必须用daemonize释放资源并挂到init下,还需要用completion等待这一过程的完成。
kthread_create是比较正牌的创建函数,这个不必要调用daemonize,用这个创建的kernel thread都挂在了kthread线程下。
从表面上来看,这两个函数非常的类似,但是实现却是相差甚远。

kthread_create是通过work_queue来实现的,kernel_thread是通过do_fork来实现的。

kthread_create:
DECLARE_WORK(work, keventd_create_kthread, &create);
调用keventd_create_kthread,keventd_create_kthread中调用kernel_thread:
    pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);

参考:
http://www.scs.ch/~frey/linux/kernelthreads.html
http://kernelnewbies.org/Simple_UDP_Server
http://mail.nl.linux.org/kernelnewbies/2006-07/msg00373.html
http://linux.sheup.com/linux/linux7553.htm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值