|
|
At the center of the UNIX onion is a program called the kernel. Although you are unlikely to deal with the kernel directly, it is absolutely crucial to the operation of the UNIX system. The kernel provides the essential services that make up the heart of UNIX systems; it allocates memory, keeps track of the physical location of files on the computer's hard disks, loads and executes binary programs such as shells, and schedules the task swapping without which UNIX systems would be incapable of doing more than one thing at a time. The kernel accomplishes all these tasks by providing an interface between the other programs running under its control and the physical hardware of the computer; this interface, the system call interface, effectively insulates the other programs on the UNIX system from the complexities of the computer. For example, when a running program needs access to a file, it cannot simply open the file; instead it issues a system call which asks the kernel to open the file. The kernel takes over and handles the request, then notifies the program whether the request succeeded or failed. To read data in from the file takes another system call; the kernel determines whether or not the request is valid, and if it is, the kernel reads the required block of data and passes it back to the program. Unlike DOS (and some other operating systems), UNIX system programs do not have access to the physical hardware of the computer. All they see are the kernel services, provided by the system call interface.
The system call interface is an example of an API, or application programming interface. An API is a set of system calls with strictly defined parameters, which allow an application (or other program) to request access to a service; it literally acts as an interface. (For example, a large database system might provide an API that allows programmers to write external programs that request services from the database.)
Note that the kernel is not indivisible. There are a small number
of kernel sub-processes which are executed by the kernel;
they are visible in the process listing when you type the
command ps -ef. Nor is the kernel the first program
that runs when you boot (start up) the UNIX system; see
``The UNIX system life cycle''.
In addition, the kernel
contains device drivers.
A device driver is a
sub-program which is designed to enable the kernel to communicate
with a peripheral device (such as a hard disk
drive, or a local area network adapter) not normally
supported by the UNIX system. When the kernel receives
a request from a program to read or write to a device which
requires a driver, it forwards the request to the device driver
to provide the service. Device drivers are linked into the kernel.
Some third party add-on components come with their own device
drivers; these can be added to the kernel by the administrator.
In addition to device drivers and special processes, the kernel keeps track of the files stored on the system. Files and devices accessed via drivers are referenced through a name space; this is an abstract space in which named objects (the files, directories and devices of the UNIX system) have a uniform interface. The kernel translates references to named objects into requests for actual data stored by means of a protocol called a filesystem or via a device driver. For further details, see ``Understanding filesystems and devices''.