x
Loading
 Loading
Hello, Guest | Login | Register

Kernel Threads

Kernel threads are used to implement background tasks inside the kernel. They are similar to user processes, but live in kernel address space. Here’s how to use them.

Threads are programming abstractions used in concurrent processing. A kernel thread is a way to implement background tasks inside the kernel. A background task can be busy handling asynchronous events or can be asleep, waiting for an event to occur. Kernel threads are similar to user processes, except that they live in kernel space and have access to kernel functions and data structures. Like user processes, kernel threads appear to monopolize the processor because of preemptive scheduling.
In this month’s “Gearheads,” let’s discuss kernel threads and develop an example that also demonstrates such as process states, wait queues, and user-mode helpers.

Built-in Kernel Threads

To see the kernel threads (also called kernel processes) running on your system, run the command ps –ef. You should see something similar to Figure One.
FIGURE ONE: A typical list of Linux kernel threads
$ ps –ef 

UID PID PPID C STIME TTY TIME CMD
root 1 0 0 22:36 ? 00:00:00 init [3]
root 2 1 0 22:36 ? 00:00:00 [ksoftirqd/0]
root 3 1 0 22:36 ? 00:00:00 [events/0]
root 38 3 0 22:36 ? 00:00:00 [pdflush]
root 39 3 0 22:36 ? 00:00:00 [pdflush]
root 29 1 0 22:36 ? 00:00:00 [khubd]
root 695 1 0 22:36 ? 00:00:00 [kjournald]

root 3914 1 0 22:37 ? 00:00:00 [nfsd]
root 3915 1 0 22:37 ? 00:00:00 [nfsd]

root 4015 3364 0 22:55 tty3 00:00:00 -bash
root 4066 4015 0 22:59 tty3 00:00:00 ps -ef
The output of ps –ef is a list…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace