sections in this module City College of San Francisco - CS260A
Linux System Administration

Module: Processes I
module list

Process Creation

Processes come from processes. This basic Unix concept begs a philosophical question. The answer is "the first process is created spontaneously by the kernel during system initialization". That first process is used to hold the ancestor of all later processes: init. init(8) will be covered in the module on Startup and Shutdown

Once a process exists, it can create a child process using a facility called fork and exec.

Though most often used in concert, fork and exec are actually two separate system calls:

fork and exec create a parent-child relationship between the forking process (the parent) and the newly-created process (the child), which is later the subject of the exec. This relationship can be seen in the execution of the simple command:

$ ls
a  b  errno-base.h.swp  x.tar
$

The execution of this command proceeds as follows:

Before we continue, let's examine some ramifications of the above scenario:

Children that cannot exit

The inability of the parent to receive the SIGCHLD signal can be due to either 

Both of these circumstances result in child that is unable to exit. Since this is equivalent to a 'living dead' state, the state is called Zombie (Z). A zombie is stripped of its resources and held in limbo waiting for the parent to respond. 

Zombies may exist for a short while on any running Unix system. The most common situation that gives rise to a zombie is that the parent is simply asleep. When it awakens, the zombie will be cleared. Although zombies do not tie up any resources (such as memory pages or compute time), they do clog up a slot in the process table and their accumulation will eventually degrade system performance. 

Background processes

If a process is run in the background, the sequence of events surrounding the fork() and exec() calls must be modified slightly. In this case, the parent does not go to sleep until the child exits: it continues to run in parallel. Other details are the same.

bash bends some of the standard rules of process handling to try to smooth the rough edges. It is often best to run a less 'friendly' shell if you want to experiment with how Unix itself works, such as the Korn shell, ksh, when investigating process and job control and signals.

Threads

Rather than using fork(), threads use one of the clone() system calls. These system calls set the child up to share certain types of data with the parent.

Preview question: On a linux system, run the following commands and examine the swapping information:
vmstat 1 1
cat /proc/swaps

Prev This page was made entirely with free software on linux:  
the Mozilla Project
and Openoffice.org    
Next

Copyright 2012 Greg Boyd - All Rights Reserved.