Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


kernel/workqueue.c
int fastcall queue_delayed_work(struct workqueue_struct *wq,
struct delayed_work *dwork, unsigned long delay)

This function first generates a kernel timer whose time-out occurs indelayedjiffies. The associated
handler function then usesqueue_workto add the work to the work queue in the normal way.

The kernel generates a standard wait queue namedevents. This queue can be used by all parts of the
kernel for which it is not worthwhile creating a separate work queue. The two functions below, whose
implementation I need not discuss in detail, must be used to place new work in this standard queue:

kernel/workqueue.c
int schedule_work(struct work_struct *work)
int schedule_delayed_work(struct delay_work *dwork, unsigned long delay)

14.5 Summary


The kernel can be activated synchronously or asynchronously. While the preceeding chapter discussed
how system calls are employed for synchronous activation, you have seen in this chapter that there is a
second, asynchronous activation method triggered from the hardware using interrupts.

Interrupts are used when the hardware wants to notify the kernel of some condition, and there are var-
ious ways that interrupts can be implemented physically. After discussing the different possibilities, we
have analyzed the generic data structures of the kernel that are employed to manage interrupts, and have
seen how to implement flow handling for various IRQ types. The kernel has to provide service routines
for IRQs, and some care is required to implement them properly. Most important, it is necessary to make
these handlers as fast as possible, and the work is therefore often distributed into a quick top half and a
slower bottom half that runs outside the interrupt context.

The kernel offers some means to defer actions until a later point in time, and I have discussed the cor-
responding possibilities in this chapter: SoftIRQs are the software equivalent to hardware IRQs, and
tasklets are built on this mechanism. While they enablethe kernel to postpone work until later, they are
notallowedtogotosleep.Thisis,however,possible with wait queues and work queues, also examined
in this chapter.
Free download pdf