Understanding the Linux Kernel
14
execution flows, that is, multiple sequences of instructions executed in the same address
space.
Multiuser systems must enforce an execution environment in which several processes can be
active concurrently and contend for system resources, mainly the CPU. Systems that allow
concurrent active processes are said to be multiprogramming or multiprocessing.
[4]
It is
important to distinguish programs from processes: several processes can execute the same
program concurrently, while the same process can execute several programs sequentially.
[4]
Some multiprocessing operating systems are not multiuser; an example is Microsoft's Windows 98.
On uniprocessor systems, just one process can hold the CPU, and hence just one execution
flow can progress at a time. In general, the number of CPUs is always restricted, and therefore
only a few processes can progress at the same time. The choice of the process that can
progress is left to an operating system component called the scheduler. Some operating
systems allow only nonpreemptive processes, which means that the scheduler is invoked only
when a process voluntarily relinquishes the CPU. But processes of a multiuser system must be
preemptive ; the operating system tracks how long each process holds the CPU and
periodically activates the scheduler.
Unix is a multiprocessing operating system with preemptive processes. Indeed, the process
abstraction is really fundamental in all Unix systems. Even when no user is logged in and no
application is running, several system processes monitor the peripheral devices. In particular,
several processes listen at the system terminals waiting for user logins. When a user inputs a
login name, the listening process runs a program that validates the user password. If the user
identity is acknowledged, the process creates another process that runs a shell into which
commands are entered. When a graphical display is activated, one process runs the window
manager, and each window on the display is usually run by a separate process. When a user
creates a graphics shell, one process runs the graphics windows, and a second process runs the
shell into which the user can enter the commands. For each user command, the shell process
creates another process that executes the corresponding program.
Unix-like operating systems adopt a process/kernel model. Each process has the illusion that
it's the only process on the machine and it has exclusive access to the operating system
services. Whenever a process makes a system call (i.e., a request to the kernel), the hardware
changes the privilege mode from User Mode to Kernel Mode, and the process starts the
execution of a kernel procedure with a strictly limited purpose. In this way, the operating
system acts within the execution context of the process in order to satisfy its request.
Whenever the request is fully satisfied, the kernel procedure forces the hardware to return to
User Mode and the process continues its execution from the instruction following the system
call.
1.4.4 Kernel Architecture
As stated before, most Unix kernels are monolithic: each kernel layer is integrated into the
whole kernel program and runs in Kernel Mode on behalf of the current process. In contrast,
microkernel operating systems demand a very small set of functions from the kernel,
generally including a few synchronization primitives, a simple scheduler, and an interprocess
communication mechanism. Several system processes that run on top of the microkernel
implement other operating system-layer functions, like memory allocators, device drivers,
system call handlers, and so on.