Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions examples/bottomhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
#define NO_GPIO_REQUEST_ARRAY
#endif

/* Macro DECLARE_TASKLET_OLD exists for compatibility.
* See https://lwn.net/Articles/830964/
*/
#ifndef DECLARE_TASKLET_OLD
#define DECLARE_TASKLET_OLD(arg1, arg2) DECLARE_TASKLET(arg1, arg2, 0L)
#endif

static int button_irqs[] = { -1, -1 };

/* Define GPIOs for LEDs.
Expand Down
18 changes: 14 additions & 4 deletions lkmpg.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2107,11 +2107,21 @@ \subsection{Detecting button presses}
\subsection{Bottom Half}
\label{sec:bottom_half}
Suppose you want to do a bunch of stuff inside of an interrupt routine.
A common way to do that without rendering the interrupt unavailable for a significant duration is to combine it with a tasklet.
A common way to avoid blocking the interrupt for a significant duration
is to defer the time-consuming part to a workqueue.
Comment on lines +2110 to +2111
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the writing for rationale.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting that the rationale behind the change needs more explanation, or
Is the issue with the tone and professionalism of the writing itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting that the rationale behind the change needs more explanation?

I meant that you can consolidate BH descriptions, such as the removal of tasklet.

This pushes the bulk of the work off into the scheduler.

The example below modifies the previous example to also run an additional task when an interrupt is triggered.

This approach helps speed up the interrupt handling process itself,
allowing the system to respond to the next hardware interrupt more quickly.

Kernel developers generally discourage using tasklets due to their design limitations,
such as memory management issues and unpredictable latencies.
Instead, they recommend more robust mechanisms like workqueues or \textbf{softirqs}.
To address tasklet shortcomings, Linux contributors introduced the BH workqueue,
activated with the \cpp|WQ_BH| flag.
This workqueue retains critical features,
such as execution in atomic (\textbf{softirq}) context on the same CPU and the inability to sleep.

The example below extends the previous code to include an additional task executed in process context when an interrupt is triggered.
\samplec{examples/bottomhalf.c}

\subsection{Threaded IRQ}
Expand Down