当前位置: 首页 > news >正文

核工业西南建设集团有限公司网站视频背景做网站背景

核工业西南建设集团有限公司网站,视频背景做网站背景,大同推广型网站建设,合肥浦发建设集团网站文章系列 1.linux工作队列 - workqueue总览 2.linux工作队列 - workqueue_struct创建 3.linux工作队列 - 把work_struct加入工作队列 4.linux工作队列 - work_struct被调用过程 把work_struct加入工作队列 把work_struct加入到工作队列workqueue的API在系列文章1有介绍这些API虽然用法不一但是最终都会调用__queue_work函数来进行实际加入操作比如APIqueue_work_on bool queue_work_on(int cpu, struct workqueue_struct *wq,struct work_struct *work) {bool ret false;unsigned long flags;local_irq_save(flags);if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) {__queue_work(cpu, wq, work);------调用到__queue_workret true;}local_irq_restore(flags);return ret; } 下面分析__queue_work的代码如下 static void __queue_work(int cpu, struct workqueue_struct *wq,struct work_struct *work) {struct pool_workqueue *pwq;struct worker_pool *last_pool;struct list_head *worklist;unsigned int work_flags;unsigned int req_cpu cpu;/** While a work item is PENDING off queue, a task trying to* steal the PENDING will busy-loop waiting for it to either get* queued or lose PENDING. Grabbing PENDING and queueing should* happen with IRQ disabled.*/WARN_ON_ONCE(!irqs_disabled());debug_work_activate(work);/* if draining, only works from the same workqueue are allowed */if (unlikely(wq-flags __WQ_DRAINING) WARN_ON_ONCE(!is_chained_work(wq)))return; retry:if (req_cpu WORK_CPU_UNBOUND)cpu wq_select_unbound_cpu(raw_smp_processor_id());//根据传入的参数struct workqueue_struct *wq来选择需要的类型/* pwq which will be used unless work is executing elsewhere */if (!(wq-flags WQ_UNBOUND))pwq per_cpu_ptr(wq-cpu_pwqs, cpu);----------------得到bound类型的pool_workqueue elsepwq unbound_pwq_by_node(wq, cpu_to_node(cpu));-----得到unbound类型的pool_workqueue /** If work was previously on a different pool, it might still be* running there, in which case the work needs to be queued on that* pool to guarantee non-reentrancy.*///work有可能已经存在另一个不同的work pool中它可能仍旧在运行为了避免重入work仍然要加入到原来的work poollast_pool get_work_pool(work);if (last_pool last_pool ! pwq-pool) {struct worker *worker;spin_lock(last_pool-lock);worker find_worker_executing_work(last_pool, work);if (worker worker-current_pwq-wq wq) {pwq worker-current_pwq;----------------------得到last的pool_workqueue} else {/* meh... not running there, queue here */spin_unlock(last_pool-lock);spin_lock(pwq-pool-lock);}} else {spin_lock(pwq-pool-lock);}/** pwq is determined and locked. For unbound pools, we could have* raced with pwq release and it could already be dead. If its* refcnt is zero, repeat pwq selection. Note that pwqs never die* without another pwq replacing it in the numa_pwq_tbl or while* work items are executing on it, so the retrying is guaranteed to* make forward-progress.*/if (unlikely(!pwq-refcnt)) {if (wq-flags WQ_UNBOUND) {spin_unlock(pwq-pool-lock);cpu_relax();goto retry;}/* oops */WARN_ONCE(true, workqueue: per-cpu pwq for %s on cpu%d has 0 refcnt,wq-name, cpu);}/* pwq determined, queue */trace_workqueue_queue_work(req_cpu, pwq, work);if (WARN_ON(!list_empty(work-entry))) {spin_unlock(pwq-pool-lock);return;}pwq-nr_in_flight[pwq-work_color];work_flags work_color_to_flags(pwq-work_color);if (likely(pwq-nr_active pwq-max_active)) {trace_workqueue_activate_work(work);pwq-nr_active;worklist pwq-pool-worklist;----------------得到pool_workqueue的worker_pool的worklistif (list_empty(worklist))pwq-pool-watchdog_ts jiffies;} else {work_flags | WORK_STRUCT_DELAYED;worklist pwq-delayed_works;}insert_work(pwq, work, worklist, work_flags);-----把work加入到worklist并唤醒spin_unlock(pwq-pool-lock); }看函数insert_work代码 static void insert_work(struct pool_workqueue *pwq, struct work_struct *work,struct list_head *head, unsigned int extra_flags) {struct worker_pool *pool pwq-pool;/* we own work, set data and link */set_work_pwq(work, pwq, extra_flags);list_add_tail(work-entry, head);---------------加入work pool的链表get_pwq(pwq);/** Ensure either wq_worker_sleeping() sees the above* list_add_tail() or we see zero nr_running to avoid workers lying* around lazily while there are works to be processed.*/smp_mb();if (__need_more_worker(pool))wake_up_worker(pool);----------------------唤醒work pool }
http://www.w-s-a.com/news/123918/

相关文章:

  • 怎么恢复网站数据库网站开发作业代做
  • 哪里建设网站最好用中国第五冶金建设公司医院网站
  • 雄安网建 网站建设订餐网站建设
  • 广州视频网站建站公司网站 体系
  • 青浦门户网站网站推广烟台公司电话
  • 湖北荆门建设银行网站wordpress购物模板下载
  • 学ui+wordpress模板北京推广优化
  • 建分类网站得花多少钱深圳设计网站开发
  • 网站集群建设和网站集约化百度商桥怎么绑定网站
  • 青岛模板网站建设价格网络品牌网站建设
  • 网站建设的几大要素网站的做网站的公司
  • 怎么登陆自己的公司网站垂直电商网站建设
  • 温州微网站制作哪里有许昌网站建设哪家最好
  • 中国中小企业网站官网网页制作工具按其制作方式分 可以分为
  • 做资源下载网站违法吗河南企业做网站
  • 网站开发总体功能设计网站建设 北京昌平
  • 辽宁省高等级公路建设局网站书画院网站建设方案
  • 本地生活网站 源码重庆本地网站有哪些
  • 企业网站域名服务器国外html响应式网站
  • 东莞网站建设策划企业网站推广策划方法
  • 网站的图片怎么制作WordPress交互式网站
  • pc网站增加手机站什么专业学网页设计制作
  • 婚庆公司网站模板wordpress用什么框架
  • 高校网站建设的时效性长沙市网站建设
  • 合肥网站建设市场四川建设网官网住房和城乡厅官网官方
  • 天行健君子以自强不息网站建设江西网站做的好的企业文化
  • 建网站内容谷歌搜索引擎优化
  • 网站建设与管理案例教程第三版答案网站建设策划书范文六篇精选
  • 建设工程项目在哪个网站查询实时网站推广的最终目的是
  • 个人网站可以做淘客网站设置的参数