Info

static inline int tasklet_trylock(struct tasklet_struct *t) {

return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);

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

If the count element 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 invoking t->func(t->data). Finally, the TASKLET_SCHED_RUN bit of the tasklet is deleted using tasklet_unlock.

If new tasklets were queued for the current processor during execution of the tasklets, the softlRQ tasklet_softirq is 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_softirq is used as a softIRQ instead of tasklet_softirq; its associated action function is tasklet_hi_action.

□ The registered tasklets are queued in the CPU-specific variable tasklet_hi_vec. This is done using tasklet_hi_schedule.

In this context, "higher priority" means that the softIRQ handler hi_softirq is executed before all 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.

Continue reading here: Data Structures

Was this article helpful?

0 0