The Linux Kernel/Processing

< The Linux Kernel

Processing: from process to CPU

Processes and TasksEdit

Process is a running user space program. Kernel can start a process with function do_execve. Processes occupy system resources, like memory, CPU time. System calls sys_fork and sys_execve are used to create new processes from user space. The process exit with an sys_exit system call.

How are the process handled within the kernel?


What are kernel threads?


How are kernel threads handled ?



Low level kernel synchronization: futexEdit

A futex (short for "fast userspace mutex") is a kernel system call that programmers can use to implement basic locking, or as a building block for higher-level locking abstractions such as semaphores and POSIX mutexes or condition variables.

A futex consists of a kernelspace wait queue that is attached to an aligned integer in userspace. Multiple processes or threads operate on the integer entirely in userspace (using atomic operations to avoid interfering with one another), and only resort to relatively expensive system calls to request operations on the wait queue (for example to wake up waiting processes, or to put the current process on the wait queue). A properly programmed futex-based lock will not use system calls except when the lock is contended; since most operations do not require arbitration between processes, this will not happen in most cases.

The basic operations of futexes are based on only two central operations —WAIT and WAKE— though some futex implementations (depending on the exact version of the Linux kernel) have a few more operations for more specialized cases.

  • WAIT (addr, val)
Checks if the value stored at the address addr is val, and if it is puts the current thread to sleep.
  • WAKE (addr, val)
Wakes up val number of threads waiting on the address addr.

Time and TimersEdit


Bottom HalvesEdit

  • softirq is internal system facility and should not be used directly. Use tasklet.