PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 15460 ubuntu 20 0 93072 5216 4028 S 0.3 0.1 0:00.04 sshd 1 root 20 0 37688 5212 3460 S 0.0 0.1 0:03.50 systemd . . .
1 2 3 4 5 6 7 8
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 37688 5212 ? Ss Apr24 0:03 /lib/systemd/systemd --system --deserialize 19 root 2 0.0 0.0 0 0 ? S Apr24 0:00 [kthreadd] . . .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
3a. DESCRIPTIONS of Fields 20. S -- Process Status The status of the task which can be one of:
D = uninterruptible sleep R = running S = sleeping T = stopped by job control signal t = stopped by debugger during trace Z = zombie
Tasks shown as running should be more properly thought of as ready to run -- their task_struct is simply represented on the Linux run-queue. Even without a true SMP machine, you may see numerous tasks in this state depending on top's delay interval and nice value.
A process in a runnable state is either using the CPU or waiting to use the CPU. A process in uninterruptable state is waiting for some I/O access, eg waiting for disk.
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 by job control signal t stopped by debugger during the tracing 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
‘S’ and ‘D’ are two sleep states, where the process is waiting for something to happen. The difference is that ‘S’ can be interrupted by a signal, while ‘D’ cannot (it is usually seen when the process is waiting for the disk).
‘T’ is a state where the process is stopped, usually via SIGSTOP or SIGTSTP. It can also be stopped by a debugger (ptrace). When you see that state, it usually is because you used Ctrl-Z to put a command on the background.
Uninterruptable processes are USUALLY waiting for I/O following a page fault.
The thread tries to access a page which is not in core (either an executable which is demand-loaded, a page of anonymous memory which has been swapped out, or a mmap()’d file which is demand loaded, which are much the same thing)
The kernel is now (trying to) load it in
The process can’t continue until the page is available.
The process/task cannot be interrupted in this state, because it can’t handle any signals; if it did, another page fault would happen and it would be back where it was.
When I say “process”, I really mean “task”, which under Linux (2.6) roughly translates to “thread” which may or may not have an individual “thread group” entry in /proc
In some cases, it may be waiting for a long time. A typical example of this would be where the executable or mmap’d file is on a network filesystem where the server has failed. If the I/O eventually succeeds, the task will continue. If it eventually fails, the task will generally get a SIGBUS or something.