- 1、本文档共14页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
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
最近下载
- 教科版小学科学四年级下册总复习试题(连线题).doc VIP
- 长虹LED42C2000黑屏故障通病维修方法分享.doc
- 教科版(2025秋)四年级科学下册总复习之连线题(含答案) .pdf VIP
- 2025年机修钳工(高级技师)职业技能鉴定理论考试题库资料(含答案).pdf
- 三字经全文带拼音完整版 打印版.pdf VIP
- 科教版小学科学四年级下册期末复习专项训练题04——连线题(含答案+详细解析).docx VIP
- 江苏省苏北四市(徐州、宿迁、淮安、连云港) 2025届高三第一次调研测试思想政治试题(含答案).pdf VIP
- 消防员心理培训课件.pptx VIP
- 2024年高考政治真题汇编《哲学与文化》.docx
- 风力发电场生态保护及恢复技术规范-DB21.PDF
文档评论(0)