在 linux 内核中有很多方法可以调度工作:定时器、tasklet、工作队列和内核线程。何时使用一种与另一种的指导方针是什么?
有很明显的因素:定时器函数和小任务不能休眠,所以它们不能等待互斥体、条件变量等。
在为我们选择驱动程序中的哪种机制时,还有哪些其他因素?
首选机制有哪些?
最佳答案
softirqs : deferred work runs in interrupt context tasklets : deferred work runs in interrupt context work queues : deferred work runs in process context softirqs : Softirqs of the same type can run concurrently on several CPUs. tasklets : Tasklets of different types can run concurrently on several CPUs, but tasklets of the same type cannot. 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
https://stackoverflow.com/questions/2147299/