HPlogo HP-UX Process Management: White Paper > Chapter 1 Process Management

Process States and transitions

» 

Technical documentation

Complete book in PDF

 » Table of Contents

Through the course of its lifetime, a process transits through several states. Queues in main memory keep track of the process by its process ID. A process resides on a queue according to its state; process states are defined in the proc.h header file. Events such as receipt of a signal cause the process to transit from one state to another.

Table 1-3 Process states

StateWhat Takes Place
idle (SIDL)Process is created by a call to fork, vfork, or exec; can be scheduled to run.
run (SRUN)Process is on a run queue, available to execute in either kernel or user mode.
stopped (SSTOP)Executing process is stopped by a signal or parent process
sleep (SSLEEP)Process is not executing; may be waiting for resources
zombie (SZOMB)Having exited, the process no longer exists, but leaves behind for the parent process some record of its execution.

 

The following figure demonstrates something of the transitions between process states.

Figure 1-4 Process states and transitions

[Process states and transitions]

When a program starts up a process, the kernel allocates a structure for it from the process table. The process is now in idle state, waiting for system resources. Once it acquires the resource, the process is linked onto a run queue and made runnable. When the process acquires a time-slice, it runs, switching as necessary between kernel mode and user mode. If a running process receives a SIGSTOP signal (as with control-Z in vi) or is being traced, it enters a stop state. On receiving a SIGCONT signal, the process returns to a run queue (in-core, runnable). If a running process must wait for a resource (such as a semaphore or completion of I/O), the process goes on a sleep queue (sleep state) until getting the resource, at which time the process wakes up and is put on a run queue (in-core, runnable). A sleeping process might also be swapped out, in which case, when it receives its resource (or wakeup signal) the process might be made runnable, but remain swapped out. The process is swapped in and is put on a run queue. Once a process ends, it exits into a zombie state.