内核线程:
#include <linux/kthread.h>struct task_struct *pthread;
int thread_func(void *data) //线程要调用的函数
{
....
....
while(1){
....
....
msleep(200);
}
}
int __init xxx_init(void)
{
....
....
pthread = kthread_run(thread_a_func, "xxx", "driver name.");
if(IS_ERR(pthread)) {
ret = PTR_ERR(pthread);
pthread = NULL;
}
}
void __exit xxx_eixt(void)
{
if(pthread)
pthread = NULL;
}