When a User Mode process invokes a system call, the CPU switches to Kernel Mode and starts the execution of a kernel function. As we will see in the next section, in the 80 × 86 architecture a Linux system call can be invoked in two different ways. The net result of both methods, however, is a jump to an assembly language function called the system call handler.
Because the kernel implements many different system calls, the
User Mode process must pass a parameter called the system call
number to identify the required system call; the
eax register is used by Linux for this
purpose. As we'll see in the section "Parameter Passing" later in
this chapter, additional parameters are usually passed when invoking a
All system calls return an integer value. The conventions for
these return values are different from those for wrapper routines. In
the kernel, positive or 0 values denote a successful termination of the
system call, while negative values denote an error condition. In the
latter case, the value is the negation of the error code that must be
returned to the application program in the
errno variable. The
errno variable is not set or used by the
kernel. Instead, the wrapper routines handle the task of setting this
variable after a return from a system call.
The system call handler, which has a structure similar to that of the other exception handlers, performs the following operations:
Saves the contents of most registers in ...