In Linux a process is a running instance of a lauched, executable program. This consist of the following:
The environment of a process includes:
Processes can be parent or child. A child process is created when a parent process forks and in doing so duplicates its own address space. Each new process is given a Process ID (PID) which is used for tracking and security. The PID and the parent's process ID (PPID) are elements of the new process environment. All processes are able to spawn child processes. In the case of Linux systems ultilising systemd all processes are children of systemd (Redhat Enterprise as an example).
When forking occurs a child process takes on the security identities, previous and current file descriptors, port and resource privileges, environment variables, and program code. Child processes can then exec their own program code. Whilst this is happening the parent process will sleep during the time that the child process is running at the same time as setting a reqeust (wait) to be signaled when the child process is done. When a child process exists, it will have closed its resources and environment. The only remaining resource is a zombie which is visible as an entry in the process table. Now the parent is signaled and awakens, cleans the process table of the child's entry and frees the last remaining resouce that the child process was using. The parent now continues executing its own code.
In true multitasking operating systems, each CPU core can be working on a process at any given time . As a process executes its code, its requirements for CPU time and resources changes. Processes are given a state which changes as circumstances dictate.
key
Name | Flag | Kernel-defined state name and description |
---|---|---|
Running |
R
|
TASK_RUNNING: The process is either executing on a CPU or waiting to run. Process can be executing user routines or kernel routines (system calls), or be queued and ready when in the Running (or Runnable) state. |
Sleeping |
S
|
TASK_INTERUPTIBLE: The process is waiting for some condition: a hardware request, system resource access, or signal. When an event or signal satisfies the condition, the process returns to Running. |
D
|
TASK_UNINTERRUPTIBLE: This process is also Sleeping, but unlike S state, does not respond to signals. Used only when process interruption may cause an unpredictable device state.
|
|
K
|
TASK_KILLABLE: Identical to the uninterruptible D state, but modified to allow a waiting task to respond to the signal that it should be killed (exit completely). Utilities frequently display Killable processes as D state.
|
|
I
|
TASK_REPORT_IDLE: A subset of state D . The kernel does not count these processes when calculating load average. Used for kernel threads. Flags TASK_UNINTERRUPTABLE and TASK_NOLOAD are set. Similar to TASK_KILLABLE, also a subset of state D . It accepts fatal signals.
|
|
Stopped |
T
|
TASK_STOPPED: The process has been Stopped (suspended), usually by being signaled by a user or another process. The process can be continued (resumed) by another signal to return to Running. |
T
|
TASK_TRACED: A process that is being debugged is also temporarily Stopped and shares the same T state flag.
|
|
Zombie |
Z
|
EXIT_ZOMBIE: A child process signals its parent as it exits. All resources except for the process identity (PID) are released. |
X
|
EXIT_DEAD: When the parent cleans up (reaps) the remaining child process structure, the process is now released completely. This state will never be observed in process-listing utilities. |