<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > linux內(nèi)核工作隊(duì)列講解和源碼詳細(xì)注釋

          linux內(nèi)核工作隊(duì)列講解和源碼詳細(xì)注釋

          作者: 時(shí)間:2016-10-08 來(lái)源:網(wǎng)絡(luò) 收藏

          4.3.2.2 schedule_delayed_work_on

          指定CPU的延遲調(diào)度工作結(jié)構(gòu), 和schedule_delayed_work相比增加了一個(gè)CPU參數(shù), 其他都相同/** * schedule_delayed_work_on - queue work in global workqueue on CPU after delay * @cpu: cpu to use * @work: job to be done * @delay: number of jiffies to wait * * After waiting for a given time this puts a job in the kernel-global * workqueue on the specified CPU. */ int schedule_delayed_work_on(int cpu,struct work_struct *work, unsigned long delay)

          { return queue_delayed_work_on(cpu, keventd_wq, work, delay);}

          /** * queue_delayed_work_on - queue work on specific CPU after delay * @cpu: CPU number to execute work on * @wq: workqueue to use * @work: work to queue * @delay: number of jiffies to wait before queueing * * Returns 0 if @work was already on a queue, non-zero otherwise. */ int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,struct work_struct *work, unsigned long delay)

          { int ret = 0;struct timer_list *timer = work->timer;if (!test_and_set_bit(0, work->pending)) { BUG_ON(timer_pending(timer));BUG_ON(!list_empty(work->entry));/* This stores wq for the moment, for the timer_fn */ work->wq_data = wq;timer->expires = jiffies + delay;timer->data = (unsigned long)work;timer->function = delayed_work_timer_fn;add_timer_on(timer, cpu);ret = 1;} return ret;} EXPORT_SYMBOL_GPL(queue_delayed_work_on);

          5. 結(jié)論

          工作隊(duì)列和定時(shí)器函數(shù)處理有點(diǎn)類(lèi)似, 都是執(zhí)行一定的回調(diào)函數(shù), 但和定時(shí)器處理函數(shù)不同的是定時(shí)器回調(diào)函數(shù)只執(zhí)行一次, 而且執(zhí)行定時(shí)器回調(diào)函數(shù)的時(shí)候是在時(shí)鐘中斷中, 限制比較多, 因此回調(diào)程序不能太復(fù)雜; 而工作隊(duì)列是通過(guò)內(nèi)核線(xiàn)程實(shí)現(xiàn), 一直有效, 可重復(fù)執(zhí)行, 由于執(zhí)行時(shí)降低了線(xiàn)程的優(yōu)先級(jí), 執(zhí)行時(shí)可能休眠, 因此工作隊(duì)列處理的應(yīng)該是那些不是很緊急的任務(wù), 如垃圾回收處理等, 通常在系統(tǒng)空閑時(shí)執(zhí)行,在xfrm庫(kù)中就廣泛使用了workqueue,使用時(shí),只需要定義work結(jié)構(gòu),然后調(diào)用schedule_(delayed_)work即可。


          上一頁(yè) 1 2 3 4 下一頁(yè)

          關(guān)鍵詞:

          評(píng)論


          相關(guān)推薦

          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();