Linux processes generally go through six major states, which are listed below:
1. Running or Runnable ( R ) – A running state has a broader concept here. Running always does not mean utilising the CPU. Even while a process is ready to run, the state is running state.
Hence, there are two sub-states, when the process is queued in the ready queue to run and when the process is actually being executed, it is in the executing sub-state as has been scheduled by the scheduler.
2. Stopped (T) – If a running process receives a stop signal, it is moved to the stopped state. A process can also be in stopped state if it has been halted by a trace while debugging. .
3. Uninterruptible sleep (D) – It is a sleeping state, process has been blocked. Mostly, process goes into an uninterruptible sleep during an IO operation.
4. Interruptible sleep (S) – It is a sleeping state i.e. a blocking state where the process is waiting for an event to occur.
5. Zombie/Defunct state(Z) – It is the process state in which process has been terminated but not reaped by its parent process.
6. Dead (X) – A process never reaches this state, as as soon as it is dead, it is gone.
Note: For BSD formats and when the stat keyword is used, additional characters may be displayed:
-
< high-priority (not nice to other users)
-
N low-priority (nice to other users)
-
L has pages locked into memory (for real-time and custom IO)
-
s is a session leader
-
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
- + is in the foreground process group.