Explanation of different process states in Linux and how to view or deal with them ?

Brief explanation of process related terms in linux.

Today we will look at a very interesting topic to understand various different process states available in Linux.

To understand this post lets look at the command output.

1. ps -aux Command Output showing process states. Look for STAT column.

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1   2896  1432 ?        Ss   Aug27   0:01 /sbin/init
root         6  0.0  0.0      0     0 ?        S    Aug27   0:00 [watchdog/0]
root         7  0.0  0.0      0     0 ?        S    Aug27   0:14 [events/0]
root        34  0.0  0.0      0     0 ?        SN   Aug27   0:00 [ksmd]
root        35  0.0  0.0      0     0 ?        S    Aug27   0:00 [aio/0]
root        36  0.0  0.0      0     0 ?        S    Aug27   0:00 [crypto/0]
root       413  0.0  0.1   2948  1244 ?        S< s  Aug27   0:00 /sbin/udevd -d
root       996  0.0  0.0      0     0 ?        S    Aug27   0:00 [jbd2/sda1-8]
root      1411  0.0  0.0  13012   812 ?        S< sl Aug27   0:00 auditd
root      1445  0.0  0.1  36084  1552 ?        Sl   Aug27   0:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root      1505  0.0  0.0   2784   844 ?        Ss   Aug27   0:02 lldpad -d
root      1518  0.0  0.0      0     0 ?        S    Aug27   0:00 [scsi_tgtd/0]
root      1524  0.0  0.0      0     0 ?        S<   Aug27   0:00 [fcoethread/0]
root      1525  0.0  0.0      0     0 ?        S    Aug27   0:00 [cnic_wq]
root      1526  0.0  0.0      0     0 ?        S    Aug27   0:00 [bnx2fc]
root      1527  0.0  0.0      0     0 ?        S<   Aug27   0:00 [bnx2fc_l2_threa]
root      1528  0.0  0.0      0     0 ?        S<   Aug27   0:00 [bnx2fc_thread/0]
root      1532  0.0  0.0   2200   368 ?        Ss   Aug27   0:00 /usr/sbin/fcoemon --syslog
dbus      1547  0.0  0.1  13552  1524 ?        Ssl  Aug27   0:00 dbus-daemon --system
root      1561  0.0  0.6  22512  5600 ?        Ssl  Aug27   0:00 NetworkManager --pid-file=/var/run/NetworkManager/NetworkManager.pid
root      1567  0.0  0.2   4864  2264 ?        S    Aug27   0:00 /usr/sbin/modem-manager
nglinux   3975  0.0  1.1  53872 10776 ?        SNl  Aug27   0:00 Terminal
nglinux   3977  0.0  0.0   2072   624 ?        SN   Aug27   0:00 gnome-pty-helper
nglinux   3978  0.0  0.1   5236  1676 pts/0    SNs  Aug27   0:00 bash
root      3998  0.0  0.3  10596  3368 pts/0    SN   Aug27   0:00 sudo su -
root      4004  0.0  0.3   8116  2752 pts/0    SN   Aug27   0:00 su -
root      4007  0.0  0.1   5240  1668 pts/0    SN+  Aug27   0:00 -bash
root      4631  0.0  0.1   3208  1740 ?        S<   03:10   0:00 /sbin/udevd -d
root      5254  0.0  0.1   2944  1196 ?        S<   09:14   0:00 /sbin/udevd -d
root      5403  0.2  0.3  11752  3568 ?        Ss   11:47   0:00 sshd: root@pts/1 
root      5406  0.0  0.1   5128  1664 pts/1    Ss   11:47   0:00 -bash
root      5433  0.0  0.1   4912  1000 pts/1    R+   11:49   0:00 ps -aux

2. Explanation of different STAT column output.

S --> Interruptible sleep(S) process which is waiting for an event to complete.
Ss --> A session leader(s) process in Interruptible sleep(S).
SN --> A low priority(N) process which is nice to others is in interruptible sleep(S).
S< s --> "<" indicates a high priority process and the process is a session leader(s) in interruptible sleep(S).
S< sl --> A multhi-threaded(l) high priority(<) session leader(s) process in interruptible sleep(S).
S< --> A high priroty(<) process in interruptible sleep(S).
SNl --> A low priority(N) multi-threaded(l) process in interruptible sleep(S) state.
SNs --> A low priority(N) session leader(s) process in interruptible sleep(S).
SN+ --> A low priority(N) interruptible sleep(S) process running in foreground(+).
R+ --> A foreground(+) running(R) process.


PROCESS STATE CODES
In the above STAT column, it shows the process state. The different process states of Linux can be found in its MAN page as follows.

PROCESS STATE CODES
       Here are the different values that the s, stat and state output
       specifiers (header "STAT" or "S") will display to describe the state of
       a process.
       D    Uninterruptible sleep (usually IO)
       R    Running or runnable (on run queue)
       S    Interruptible sleep (waiting for an event to complete)
       T    Stopped, either by a job control signal or because it is being
            traced.
       W    paging (not valid since the 2.6.xx kernel)
       X    dead (should never be seen)
       Z    Defunct ("zombie") process, terminated but not reaped by its
            parent.

       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

 

3. Explanation of different Process States.

       
1. Running or Runnable  (R) 
2. Sleeping or waiting
      Interruptible sleep mode (S)
      Uninterruptible sleep mode (D)
3. Stopped (T)
4. Zombie (Z)

1. Running or Runnable (R) : A running process or might be waiting for its turn to process by the scheduler.
2. Sleeping or waiting : A waiting process for some of its sub-task to finish are sent into sleeping state.
Interruptible sleep mode (S) : This sleep mode can be interrupted by us and this process can be killed/changed.
Uninterruptible sleep mode (D) : This sleep mode can't be interrupted and such processes can't be killed explicitly.
3. Stopped (T) : A stopped or suspended process.
4. Zombie (Z) : Those terminated or killed processes(or the processes which has completed their execution) which are not yet cleared from system process table.

4. Sorting Output by process states
This is very useful command and can be helpful to identify a type of processes on system, say zombie processes, uninterruptible sleep process, etc.

[root@nglinux ~]# ps -eo stat,pid,ppid,comm | sort -n -k 1
R+    6917  6616 ps
S        2     0 kthreadd
S        3     2 migration/0
S        4     2 ksoftirqd/0
S        5     2 stopper/0
S        6     2 watchdog/0
S        7     2 events/0
S        8     2 events/0
S        9     2 events_long/0
S       10     2 events_power_ef
S       11     2 cgroup
S       12     2 khelper
S       13     2 netns
S       14     2 async/mgr
S       15     2 pm
S       16     2 sync_supers
S       17     2 bdi-default
S       18     2 kintegrityd/0
S       19     2 kblockd/0
S       20     2 kacpid
S       21     2 kacpi_notify
S       22     2 kacpi_hotplug
S       23     2 ata_aux
S       24     2 ata_sff/0
S       25     2 ksuspend_usbd
S       26     2 khubd
S       27     2 kseriod
S       28     2 md/0
S       29     2 md_misc/0
S       30     2 linkwatch
S       31     2 khungtaskd
S       32     2 lru-add-drain/0
S       33     2 kswapd0
S       35     2 aio/0
S       36     2 crypto/0
S       43     2 kthrotld/0
S       45     2 kpsmoused
S       46     2 usbhid_resumer
S       47     2 deferwq
S       80     2 kdmremove
S       81     2 kstriped
S      172     2 scsi_eh_0
S      173     2 scsi_eh_1
S      204     2 mpt_poll_0
S      205     2 mpt/0
S      206     2 scsi_eh_2
S      210     2 scsi_eh_3
S      308     2 flush-8:16
S      310     2 jbd2/sdb1-8
S      311     2 ext4-dio-unwrit
S      996     2 jbd2/sda1-8
S      997     2 ext4-dio-unwrit
S     1090     2 kauditd
S     1151     2 ib_addr
S     1156     2 infiniband/0
S     1165     2 ib_mcast
S     1170     2 iw_cm_wq
S     1175     2 ib_cm/0
S     1180     2 rdma_cm
S     1201     2 ipoib_flush
S     1518     2 scsi_tgtd/0
S     1519     2 fc_exch_workque
S     1520     2 fc_rport_eq
S     1523     2 fcoe_work/0
S     1525     2 cnic_wq
S     1526     2 bnx2fc
S     1567     1 modem-manager
S     1644  1643 hald-runner
S     1690  1644 hald-addon-inpu
S     1693  1644 hald-addon-acpi
S     1778     1 mysqld_safe
S     2131  2097 httpd
S     2132  2097 httpd
S     2133  2097 httpd
S     2134  2097 httpd
S     2135  2097 httpd
S     2136  2097 httpd
S     2137  2097 httpd
S     2138  2097 httpd
S     2292     1 dbus-launch
S     2304     1 devkit-power-da
S     2358     1 polkitd
S     3805  2144 authatieventsd.
S     3922     1 udisks-daemon
S     3928  3922 udisks-daemon
S     3949  3932 gconf-helper
S     6661  1561 dhclient
S+    6918  6616 sort
S<    1524     2 fcoethread/0
S<    1527     2 bnx2fc_l2_threa
S<    1528     2 bnx2fc_thread/0
S<    4631   413 udevd
S<    5254   413 udevd
S< s    413     1 udevd
S< sl  1411     1 auditd
S< sl  3932     1 pulseaudio
SN      34     2 ksmd
SN    3839     1 dbus-launch
SN    3873     1 xfconfd
SN    3892     1 xfsettingsd
SN    3893  3888 xfwm4
SN    3896  3888 xfdesktop
SN    3900     1 gvfsd
SN    3905     1 gvfs-gdu-volume
SN    3906     1 xfce4-settings-
SN    3913     1 polkit-gnome-au
SN    3925  3895 panel-6-systray
SN    3934     1 restorecond
SN    3936     1 gvfsd-trash
SN    3941     1 nm-applet
SN    3951     1 gconfd-2
SN    3954  3895 xfce4-oragecloc
SN    3956  3895 xfce4-brightnes
SN    3960  3895 panel-4-xfce4-n
SN    3977  3975 gnome-pty-helpe
SN    3998  3978 sudo
SN    4004  3998 su
SN+   4007  4004 bash
SNl   2374     1 rtkit-daemon
SNl   2398  2183 gdm-session-wor
SNl   3888  3831 xfce4-session
SNl   3895  3888 xfce4-panel
SNl   3958  3895 xfce4-mixer-plu
SNl   3974     1 Thunar
SNl   3975  3974 Terminal
SNs   3831  2398 sh
SNs   3848  3831 ssh-agent
SNs   3878     1 gpg-agent
SNs   3907     1 xfce4-power-man
SNs   3930     1 xfce4-power-man
SNs   3978  3975 bash
SNsl  3840     1 dbus-daemon
STAT   PID  PPID COMMAND
Sl    1445     1 rsyslogd
Sl    1985  1778 mysqld
Sl    2183  2152 gdm-simple-slav
Sl    2222     1 console-kit-dae
Sl    3821     1 gnome-keyring-d
Ss       1     0 init
Ss    1505     1 lldpad
Ss    1532     1 fcoemon
Ss    1592     1 cupsd
Ss    1626     1 wpa_supplicant
Ss    1631     1 acpid
Ss    1739     1 sshd
Ss    2086     1 abrtd
Ss    2097     1 httpd
Ss    2109     1 crond
Ss    2124     1 atd
Ss    2144     1 atieventsd
Ss    5403  1739 sshd
Ss    6613  1739 sshd
Ss    6616  6613 bash
Ss+   2157     1 mingetty
Ss+   2159     1 mingetty
Ss+   2161     1 mingetty
Ss+   2163     1 mingetty
Ss+   2170     1 mingetty
Ss+   2186  2183 Xorg
Ss+   5406  5403 bash
Ssl   1547     1 dbus-daemon
Ssl   1561     1 NetworkManager
Ssl   1643     1 hald
Ssl   1720     1 pcscd
Ssl   2152     1 gdm-binary
[root@nglinux ~]# 
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments