Linux – How to a process in “interruptible sleep” state use 100% CPU

linuxprocess

According to this reference, a process has the following states

R  running or runnable (on run queue)
D  uninterruptible sleep (usually IO)
S  interruptible sleep (waiting for an event to complete)
Z  defunct/zombie, terminated but not reaped by its parent
T  stopped, either by a job control signal or because it is being traced

In the sleep state, it is not expected that process consumes CPU time, however in the output below, I see that a process is using 100% of cpu and at the same time, it is in S state.

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
32643 root      20   0 13736 7748  472 R   98  0.0   2:59.30 bzip2
29504 satam     20   0 1063m 779m 3824 S  100  2.4   1242:54 stencil
31923 root      20   0 15092 1224  848 D   14  0.0   1:39.96 find

How that is possible and what does that mean?

Best Answer

"uninterruptible sleep" means that the process is waiting on I/O (disk operations for example). But given that the CPU is running the process, even though it isn't doing work, the CPU is still "stuck" waiting for it to complete the io, so it can get on with something else - to schedule another task. So this consumes 100% of cycles of the CPU when the process is in D mode.

So it is in sleep mode, in than that it isn't doing any CPU work, but is uninterruptible which means the CPU can't do anything else.

In a multi-core system, the other cores are available for other tasks.

Related Question