In my last article, I gave a general overview of the function and importance of operating systems. Here I describe the main constituents of the UNIX operating system and its operation.
The UNIX operating system has two major components: the kernel and the commands. The kernel is a program which starts executing when the computer is turned on. It has knowledge of, and exclusive control over, the computer's hardware. It also provides and enforces protection, keeping users separate. To systems programmers, it defines the essence of the operating system; to them the kernel is the system. The commands are a set of application programs which are distributed with the operating system. These increase the system's usability, providing a high level interface to the kernel. To users, it is the commands which define UNIX.
Application programs can communicate with the kernel through a (reasonably) well defined set of instructions called system calls. Because these are the exclusive interface to the kernel, they ensure programs' portability across UNIX platforms, provided they are in conformance with the calls' definitions and make no assumptions about hardware. (This is a broad statement which should be tempered by noting that, historically, the interface has not been well defined, static, or standardized.) Systems programmers work extensively with the system interface, reveling in the use of obscure system calls which are typically described as "This function is used by special programs and not by ordinary applications." Knowledge of this is what makes one a "UNIX programmer." Application programmers should note that system calls differ from subroutine or function calls in that they are processed by the kernel, with the CPU in supervisor (or kernel) mode. Only then are restricted commands available, such as those which access hardware.
In operation, UNIX is very dynamic. When the kernel receives a request to execute a program, it makes a process, which represents the dynamic state of the program in operation. This is controlled by the kernel until it terminates and is removed from the system. Processes are organized in a parent-child relationship with each having exactly one parent and zero or more children. The sole exception is a special process called init which is an ancestor of all other processes. Other than init, each process is created as a child of an existing process. Most processes are short lived, terminating on completion of their assigned task. However, there are special long lived processes called daemons which normally don't terminate until the operating system stops. These wait for a task, perform it, sometimes through a child process, then return to waiting. UNIX uses daemons extensively for such services as printing, networking, e-mail and error logging.
Users generally interact with the kernel through a special command called a shell. Although the operating system includes at least one shell, any shell can be used, even those written by users. Shells are command interpreters which provide high level interfaces to the kernel. They interpret the user's keystrokes, execute requested programs through new processes and display their output on a terminal. Whenever a user logs into a UNIX system it is a shell process which controls the session.
UNIX supports simultaneous users and processes; it is said to be a multi-user, multitasking system. Although users and their processes are kept separate by the kernel, there is a special user called root or super user who has access to restricted commands and whose processes have authority over all other processes. This is the system administration mode, used by system administrators for maintenance. Because of the potential for disaster if used incorrectly, root privileges within an organization are generally highly restricted. Sometimes system administrators can be heard to mutter "Who am I?" because they want to ensure they are in root mode only when necessary. The UNIX command whoami, of course, gives the answer.
No discussion of UNIX would be complete without mention of its file system. This controls the orderly storage and retrieval of files. Files contain the kernel program, the commands, user programs and data. Seismic data sets may be contained in the UNIX file system, but often are stored in proprietary file systems or in raw form on magnetic tape.
This completes my overview of operating systems in general and the UNIX system in particular. Those who understand the concepts of the kernel, the commands, processes, daemons, shells and the file system will be in a good position to understand the specific topics which I will address in future articles.