Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


If the corresponding bit has not yet been set, it is set now.

If thecountelement is not equal to 0, the tasklet is regarded as deactivated. In this case, the code is not
executed.

Once both checks have been passed successfully, the kernel executes the handler function of the
tasklet with the corresponding function parameters by invokingt->func(t->data). Finally, the
TASKLET_SCHED_RUNbit of the tasklet is deleted usingtasklet_unlock.

If new tasklets were queued for the current processor during execution of the tasklets, the softIRQ
TASKLET_SOFTIRQis raised to execute the new tasklets as soon as possible. (Because the code needed
to do this is not particularly interesting, it is not included above.)

In addition to normal tasklets, the kernel uses a second kind of tasklet of a ‘‘higher‘‘ priority.
Its implementation is absolutely identical to that of normal tasklets except for the following
modifications:

❑ HI_SOFTIRQis used as a softIRQ instead ofTASKLET_SOFTIRQ; its associated action function is
tasklet_hi_action.
❑ The registered tasklets are queued in the CPU-specific variabletasklet_hi_vec.Thisisdone
usingtasklet_hi_schedule.

In this context, ‘‘higher priority‘‘ means that the softIRQ handlerHI_SOFTIRQis executedbeforeall other
handlers — particularly before network handlers that account for the main part of software interrupt
activity.

Currently, mostly sound card drivers make use of this alternative because deferring actions too long can
impair the sound quality of audio output. But also network cards for high-speed transmission lines can
profit from this mechanism.

14.4 Wait Queues and Completions
Wait queuesare used to enable processes to wait for a particular event to occur without the need for
constant polling. Processes sleep during wait time and are woken up automatically by the kernel when
the event takes place.Completionsare mechanisms that build on wait queues and are used by the kernel
to wait for the end of an action. Both mechanisms are frequently used, primarily by device drivers, as
shown in Chapter 6.

14.4.1 Wait Queues


Data Structures


Each wait queue has a head represented by the following data structure:

<wait.h>
struct __wait_queue_head {
spinlock_t lock;
struct list_head task_list;
};
typedef struct __wait_queue_head wait_queue_head_t;
Free download pdf