kthread_run是linux内核定义的一个宏它包含:
1)kthread_create(task_id);//创建内核线程
2)wake_up_process(&task_id);//投入运行内核线程
kthread_run一旦执行线程会一直运行下去,只有遇到kthread_should_stop函数或者kthread_stop()函数,才停止运行;
代码如下:
include/linux/Kthread.h
#define kthread_run(threadfn, data, namefmt, ...) \
({ \
struct task_struct *__k \
= kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
if (!IS_ERR(__k)) \
wake_up_process(__k); \
__k; \
})