An operating system is composed of a kernel, possibly some servers, and posssibly some user-level libraries. The kernel provides operating system services through a set of procedures, which may be invoked by user processes through system calls. System calls look like procedure calls when they appear in a program, but transfer control to the kernel when they are invoked at run time. ( read is an example of a system call in Unix.)
In some operating systems, the kernel and user-processes run in a single (physical or virtual) address space. In these systems, a system call is simply a procedure call. In more robust systems, the kernel runs in its own address space and in a special privileged mode in which it can execute instructions not available to ordinary user processes. In such systems, a system call invokes a trap as discussed below.
A trap is a hardware event that invokes a trap handler in the kernel. The trap indicates, in appropriate hardware status fields, the kind of trap. Traps may be generated implicitly by the hardware to signal events such as division by zero and address faults (which we will discuss later), or explicitly by a process when it executes a special instruction. Explicit or user-initiated traps are used to handle system calls. A system call stores the name of the call and its arguments on the stack and generates a user-initiated trap. The trap handler in the kernel knows, from the type of the trap, that it is a user-initiated trap asking for a system call, finds the name of the systems call, and calls the appropriate kernel procedure to handle the call passing it the arguments stored on the stack.
We will later consider the various techniques for structuring the kernel. As we shall see, kernels may be layered, object-oriented, or decomposed into kernel processes.
Not all operating services have to be provided by the kernel. Modern operating systems also define servers, which are user processes that offer operating system services to other processes. These services are invoked by clients through interprocess communication (IPC) primitives. We shall see later the rationale for transferring functionality from the kernel to servers. We shall also see the minimum functionality that needs to be supported in the kernel. In micorkernel-based systems, the kernel provides this minimum functionality.
The cost of invoking system calls and IPC primitives is more than the cost of invoking a simple procedure call when multiple address spaces are supported by the system. Therefore, as we shall see later, some of the traditional OS functionality is sometimes also provided by user-level libraries.