linux - 何时在 linux 内核中使用内核线程与工作队列

在 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/

相关文章:

linux - 如何从 Linux 命令行彻底关闭 Eclipse?

linux - 从核心转储中获取堆栈跟踪

linux - Ubuntu中的Prolog编程

c - 如何等待非子进程退出

linux - 具有多个 execStart 的 Systemd

linux - bash 管道处理

linux - crt1.o : In function `_start' : - undefine

c - 关闭标准输出和标准输入文件描述符后重新打开它们

linux - 为什么用 grep -q 退出代码 141?

linux - 我应该如何从非 root Debian Linux 守护进程登录?