jump to navigation

kernel synchronization study note (1) June 20, 2007

Posted by TSAI HONG-BIN in Linux.

To understand how linux kernel synchronizes is a huge task… and I finally found out how bad my OS concepts is at reading.

Three main structures that closely relate to kernel synchronization and scheduling: softirq, tasklet and work queue.

Before digging into each structure, we must know that the term “context” is used to describe some binary code runs in CPU. So if you may recall, “context switching” refers to the switch of processes run in CPU. A context runs as a process is called process context, in addition to regular processes, a CPU needs to deal with interrupts (either Hardware or Software). Thus the context runs as an interrupt handler is called interrupt context.

The main difference between process context and interrupt context is that process context can block, while interrupt context can’t.

“deferrable functions” are non-urgent interruptible kernel functions (i.e. softirq and tasklet) that run in interrupt context. Work queue, however, runs in process context.

tasklets are implemented on top of softirqs. the structure of tasklet is defined in ~/linux-src/include/linux/interrupt.h. Besides, the enumeration of softirq signals are defined several lines before tasklet_struct. As the comment says, “For almost all the purposes tasklets are more than enough.” If one needs to write a device driver, tasklets should be sufficient.

Work queue, however, is for creating a process that sleeps if necessary. For example, waits for user data.



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: