网站大量收购独家精品文档,联系QQ:2885784924

linux学习之workqueue(Linux学习之workqueue).doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 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

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档