Chapter 1. Introduction to the Linux Kernel

Overview of Operating Systems and Kernels

The operating system is the parts of the system responsible for basic use and administration. This includes the kernel and device drivers, boot loader, command shell or other user interface, and basic file and system utilities.

The kernel is the innermost portion of the operating system. It is the core internals: the software that provides basic services for all other parts of the system, manages hardware, and distributes system resource.

Typical components of a kernel are:

Kernel-Space and User-Space *

When executing kernel code, the system is in kernel-space executing in kernel mode. When running a regular process, the system is in user-space executing in user mode.

System Calls and Library Calls *

Applications communicate with the kernel via system calls (Figure 1.1). An application typically calls functions in a library (e.g. C library) which rely on the system call interface to instruct the kernel to carry out tasks on the application's behalf.

When an application executes a system call, the kernel is executing on behalf of the application. Furthermore, the application is said to be executing a system call in kernel-space, and the kernel is running in process context. This relationship (that applications call into the kernel via the system call interface) is the fundamental manner in which applications get work done.

Interrupts

The kernel manages the system’s hardware through interrupts. When hardware wants to communicate with the system, it issues an interrupt that interrupts the processor, which in turn interrupts the kernel. A number identifies interrupts and the kernel uses this number to execute a specific interrupt handler to process and respond to the interrupt. To provide synchronization, the kernel can disable interrupts (either all interrupts or just one specific interrupt number). In Linux, the interrupt handlers do not run in a process context. Instead, they run in a special interrupt context that is not associated with any process. This special context exists solely to let an interrupt handler quickly respond to an interrupt, and then exit.

Figure 1.1 Relationship between applications, the kernel, and hardware.

In Linux, we can generalize that each processor is doing exactly one of three things at any given moment:

Linux Versus Classic Unix Kernels

Notable differences exist between the Linux kernel and classic Unix systems:

Linux Kernel Versions

Linux kernels come in two flavors: stable and development.

Figure 1.2 Kernel version naming convention.

The Linux Kernel Development Community

The main forum for this community is the Linux Kernel Mailing List (oft-shortened to lkml). Subscription information is available at http://vger.kernel.org.