Controlling Deferred Execution in the Kernel
内核中的延迟执行控制
A common problem in kernel development is controlling when a specific task should be done. Kernel code often executes in contexts where some actions (sleeping, for example, or calling into filesystems) are not possible.
内核开发中的一个常见问题是如何控制特定任务的执行时机。内核代码经常在一些受限的上下文中执行,在这些情况下,某些操作(例如休眠或调用文件系统)是不可行的。
Other actions, while possible, may prevent the kernel from taking care of a more important task in a timely manner.
此外,即使某些操作可以执行,它们也可能会阻碍内核及时处理更重要的任务。
The kernel community has developed a number of deferred-execution mechanisms designed to ensure that every task is handled at the right time.
为了解决这一问题,内核社区开发了多种延迟执行机制,以确保每项任务都能在适当的时机执行。
One of those mechanisms, tasklets, has been eyed for removal for years; that removal might just happen in the near future.
其中之一——tasklet 机制,多年来一直被认为应该移除;这种移除可能在不久的将来成为现实。
Deferred Execution in Interrupt Handlers
中断处理程序中的延迟执行
One context where deferred execution is often needed is interrupt handlers.
延迟执行最常见的应用场景之一是中断处理程序。
An interrupt diverts a CPU from whatever it was doing at the time and must be handled as quickly as possible; sleeping in an interrupt handler is not even remotely an option.
中断会打断 CPU 当前正在执行的任务,因此必须尽快处理;在中断处理程序中休眠是绝对不允许的。
So interrupt handlers typically just make a note of what needs to be done, then arrange for the actual work to be done in a more forgiving context.
因此,中断处理程序通常只是记录需要执行的任务,并安排在一个更宽松的上下文中执行实际工作。
There are se