CASE STUDY 1: UNIX AND LINUX
10.3 PROCESSES IN UNIX
In the previous sections, we started out by looking at UNIX as viewed from
the keyboard, that is, what the user sees at the terminal. We gave examples of
shell commands and utility programs that are frequently used. We ended with a
brief overview of the system structure. Now it is time to dig deeply into the ker-
nel and look more closely at the basic concepts UNIX supports, namely, processes,
memory, the file system, and input/output. These notions are important because
the system calls—the interface to the operating system itself—manipulate them.
For example, system calls exist to create processes, allocate memory, open files,
and do I/O.
Unfortunately, with so many versions of UNIX in existence, there are some
differences between them. In this chapter, we will emphasize the features com-
mon to all of them rather than focus on any one specific version. Thus in certain
sections (especially implementation sections), the discussion may not apply
equally to every version.
10.3.1 Fundamental Concepts
The only active entities in a UNIX system are the processes. UNIX processes
are very similar to the classical sequential processes that we studied in Chap 2.
Each process runs a single program and initially has a single thread of control. In
other words, it has one program counter, which keeps track of the next instruction
to be executed. Most versions of UNIX allow a process to create additional
threads once it starts executing.
UNIX is a multiprogramming system, so multiple, independent processes may
be running at the same time. Each user may have several active processes at
once, so on a large system, there may be hundreds or even thousands of processes
running. In fact, on most single-user workstations, even when the user is absent,
dozens of background processes, called
are running. These are started
automatically when the system is booted. (‘‘Daemon’’ is a variant spelling of
‘‘demon,’’ which is a self-employed evil spirit.)
A typical daemon is the
. It wakes up once a minute to check if
there is any work for it to do. If so, it does the work. Then it goes back to sleep
until it is time for the next check.
This daemon is needed because it is possible in UNIX to schedule activities
minutes, hours, days, or even months in the future. For example, suppose a user
has a dentist appointment at 3 o’clock next Tuesday. He can make an entry in the
cron daemon’s database telling the daemon to beep at him at, say, 2:30. When the
appointed day and time arrives, the cron daemon sees that it has work to do, and
starts up the beeping program as a new process.
The cron daemon is also used to start up periodic activities, such as making