Wiley Professional Linux Kernel Architecture 978-0-470-34343-2 Benutzerhandbuch

Produktcode
978-0-470-34343-2
Seite von 34
Mauerer
runc01.tex
V2 - 09/04/2008
4:13pm
Page 4
Chapter 1: Introduction and Overview
concept. Figure 1-1 provides a rough initial overview about the layers that comprise a complete Linux
system, and also about some important subsystems of the kernel as such. Notice, however, that the
individual subsystems will interact in a variety of additional ways in practice that are not shown in the
figure.
Applications
Userspace
C Library
Kernel space
Hardware
Device
drivers
Core kernel
System Calls
Networking
Device Drivers
Filesystems
VFS
Memory mgmt
Architecture specific code
Process mgmt
Figure 1-1: High-level overview of the structure of the Linux kernel and the
layers in a complete Linux system.
1.3.1
Processes, Task Switching, and Scheduling
Applications, servers, and other programs running under Unix are traditionally referred to as processes.
Each process is assigned address space in the virtual memory of the CPU. The address spaces of the indi-
vidual processes are totally independent so that the processes are unaware of each other — as far as each
process is concerned, it has the impression of being the only process in the system. If processes want to
communicate to exchange data, for example, then special kernel mechanisms must be used.
Because Linux is a multitasking system, it supports what appears to be concurrent execution of several
processes. Since only as many processes as there are CPUs in the system can really run at the same
time, the kernel switches (unnoticed by users) between the processes at short intervals to give them the
impression of simultaneous processing. Here, there are two problem areas:
1.
The kernel, with the help of the CPU, is responsible for the technical details of task switch-
ing. Each individual process must be given the illusion that the CPU is always available. This
is achieved by saving all state-dependent elements of the process before CPU resources are
withdrawn and the process is placed in an idle state. When the process is reactivated, the
exact saved state is restored. Switching between processes is known as task switching.
2.
The kernel must also decide how CPU time is shared between the existing processes. Impor-
tant processes are given a larger share of CPU time, less important processes a smaller share.
The decision as to which process runs for how long is known as scheduling.
1.3.2
U
NIX
Processes
Linux employs a hierarchical scheme in which each process depends on a parent process. The kernel
starts the
init
program as the first process that is responsible for further system initialization actions
and display of the login prompt or (in more widespread use today) display of a graphical login interface.
init
is therefore the root from which all processes originate, more or less directly, as shown graphically
4