kthread内核线程
来源:互联网 发布:移动网络玩dnf组队卡 编辑:程序博客网 时间:2024/05/22 08:42
1. 使用kthread_create创建线程:
struct task_struct *kthread_create(int (*threadfn)(void *data),
void *data,
const char *namefmt, ...);
这个函数可以像printk一样传入某种格式的线程名
线程创建后,不会马上运行,而是需要将kthread_create() 返回的task_struct指针传给wake_up_process(),然后通过此函数运行线程。
2. 当然,还有一个创建并启动线程的函数:kthread_run
struct task_struct *kthread_run(int (*threadfn)(void *data),void *data,
const char *namefmt, ...);
3. 线程一旦启动起来后,会一直运行,除非该线程主动调用do_exit函数,或者其他的进程调用kthread_stop函数,结束线程的运行。
int kthread_stop(struct task_struct *thread);
kthread_stop() 通过发送信号给线程。
如果线程函数正在处理一个非常重要的任务,它不会被中断的。当然如果线程函数永远不返回并且不检查信号,它将永远都不会停止。
4.kthread_run() -- 创建并唤醒线程
driver_probe_device() --> kthread_run()linux-2.6.21.5/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; \
})
- kthread内核线程
- 内核线程结构--KTHREAD
- Linux内核线程kthread
- Linux 中的IPC(二)-----内核线程(Kthread)
- 运行不息的内核线程kthread
- 运行不息的内核线程kthread
- 运行不息的内核线程kthread
- 运行不息的内核线程kthread
- 运行不息的内核线程kthread
- 运行不息的内核线程kthread
- 运行不息的内核线程kthread
- linux2.6内核kthread 内核线程机制解析(自己写的额注释)
- linux模块编程(二)——运行不息的内核线程kthread
- linux模块编程(二)——运行不息的内核线程kthread
- linux模块编程(二)——运行不息的内核线程kthread
- linux模块编程(二)——运行不息的内核线程kthread
- Kthread
- kthread
- Android入门之SharedPreferences
- 怎么签购房合同 签购房合同要注意什么
- [SMS]SMS内容的7bit和UCS2编码方式简介
- Hive-Based Registry使用
- android Activity android:launchMode="singleInstance" 与 startActivityForResult
- kthread内核线程
- while 指针 字符串
- C++定义不能被继承的类
- 本人新书 windows 8权威指南 希望大家喜欢和支持
- 创建不能改变大小的对话框
- Android开发环境搭建(jdk+eclip+android sdk)
- Office 2010安装错误 1042 无法打开注册表项
- 指针 数组
- Java基础_标识符