When to use kernel threads vs workqueues in the linux kernel

前端 未结 3 1119
暗喜
暗喜 2020-12-07 09:58

There are many ways to schedule work in the linux kernel: timers, tasklets, work queues, and kernel threads. What are the guidelines for when to use one vs another?

3条回答
  •  一生所求
    2020-12-07 10:35

    softirqs : deferred work runs in interrupt context
    tasklets : deferred work runs in interrupt context
    work queues : deferred work runs in process context
    
    softirqs : cannot run simultaneously on different CPU's
    tasklets : cannot run simultaneously on different CPU's
    work queues : can run simultaneously on different CPU's
    
    softirqs : cannot go to sleep
    tasklets : cannot go to sleep
    work queues : can go to sleep
    
    softirqs : cannot be preempted/schedule
    tasklets : cannot be preempted/schedule
    work queues : maybe be preempted/schedule
    
    softirqs : not easy to use
    tasklets : easy to use
    work queues : easy to use
    

提交回复
热议问题