- 122
- 0
- 约1.08万字
- 约 14页
- 2017-08-20 发布于河南
- 举报
linux学习之workqueue(Linux学习之workqueue)
linux学习之workqueue(Linux学习之workqueue)
文件路径:内核/内核/ C队列。
include/linux/h队列。
入口函数:init_workqueues() -创建每个CPU的workqueue
-创建每个workqueue的调度员create_worker()
-创建系统开机后一系列默认的workqueue。
如默认使用的schedule_work()即使用system_wq这个workqueue。
调用
create_worker() -为调度员工人分配内存
-根据on_unbound_cpu标志位确定采用依赖CPU的kthread_create_on_node()
还是不依赖CPU的kthread_create()来创建worker_thread,
~ 依赖CPU,则再绑定一下。
调用
worker_thread() -通过转到woke_up做死循环,确保该螺纹一直运行。无任务时转至空载(空闲)状态。
-通过need_more_worker()函数来确定当前是否有高优先级任务需要新开螺纹来执行。
-通过manage_workers()进行检查,调整创建工人时必须的两个条件,
need_to_create_worker为真和may_start_working为假。
-执行核心process_one_work()。
PS,根据标志位优先执行高优先级任务所开辟的线程,也通过process_one_work()。
调用
process_one_work() -通过work_func_t F =工作-功能;取得用户驱动设置的处理函数
-如果全局的gcwq有高优先级的工作需要执行,唤醒执行。
-使用F(工作);来执行调用点的处理函数。即用户驱动的处理函数在这里将被执行。
-最后进行一些清理标记位,释放资源,删除工作的工作。
结束
H的队列。
create_workqueue()以及create_singlethread_workqueue()采用的是宏定义,调用宏alloc_workqueue()。
实际实现函数为__alloc_workqueue_key()函数。在__alloc_workqueue_key()中,主要就是分配内存,初始
化列表,初始化工人,创建工作者线程等工作。
CWQ: a global queue for a CPU
The structure of struct work_struct {} for the user directly
The structure of struct worker {} working thread used, mainly is used to manage the work to join in the queue,
Determines whether a new thread needs to be opened, tasks in the execution queue, and so on, determining which thread worker_struct will execute by that thread.
Struct global_cwq {} each CPU has a gcwq, mainly to complete the work queue except for emergency task memory recovery,
And tasks in the CPU offline process, all tasks outside of these two tasks.
These two tasks are extremely high priority and extremely urgent tasks, and they will be implemented directly by worker to avoid being managed.
The work queue struct cpu_workqueue_struct {} on specific CPU
Struct wq_flusher {} flush empties structure, is not important.
Struct workqueue_struct {} the work queue structure, directly from the work_struct structure, if it is more than CPU,
Work_struct is formed by cpu_workqueue_struct, and then the workqueue_struct is co
您可能关注的文档
- coreldraw题库(coreldraw题库).doc
- 图表统计在应用问题教学中的尝试(The attempt of chart statistics in the teaching of applied problems).doc
- 图解系列(Graphic series).doc
- 圆的面积---邱子珍(The area of the circle --- Qiu Zizhen).doc
- 土壤污染(soil pollution).doc
- 土建施工员应该知道的数据(The data that the builder should know).doc
- 土建管理(Civil Engineering Management).doc
- 土楼(Tulou).doc
- 土豆的营养价值(The nutritional value of potatoes).doc
- 圣典(Canon).doc
- linux操作系统下以不同颜色命名的文件类型(A file type named under different colors in the Linux operating system).doc
- linux查看cpu(Linux view CPU).doc
- linux配置iptables防火墙(Linux configure the iptables firewall).doc
- linux防火墙基本知识(Basic knowledge of Linux Firewall).doc
- list控件(List control).doc
- looknstop防火墙(Looknstop firewall).doc
- led工艺初步介绍(led工艺初步介绍).doc
- love forever歌词(永远的爱歌词).doc
- low carboon life(低碳生活).doc
- mac地址修改大法(MAC address modification method).doc
最近下载
- 水质模型软件:EFDC二次开发_(9).EFDC二次开发实例-水质预测.docx VIP
- 水质模型软件:EFDC二次开发_(8).EFDC二次开发案例分析.docx VIP
- JC_T 2723-2022CN 预应力混凝土实心方桩.docx
- 水质模型软件:EFDC二次开发_(8).EFDC二次开发基础-编程语言和工具.docx VIP
- 安东帕流变学入门手册.pdf VIP
- 水质模型软件:EFDC二次开发_(7).EFDC与GIS的集成.docx VIP
- 苯、甲苯及二甲苯分离过程工艺设计说明书.pdf VIP
- 水质模型软件:EFDC二次开发_(7).高级编程技术在EFDC二次开发中的应用.docx VIP
- 康耐视相机标定及设置.pdf VIP
- 水质模型软件:EFDC二次开发_(6).EFDC模型的优化与校准方法.docx VIP
原创力文档

文档评论(0)