@kyanny's blog

My thoughts, my life. Views/opinions are my own.

プロセスの状態を表す `S' とか `R' とか `D' についてメモ

`D' ってなんだっけ、と思って少し調べた。




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
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

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



w: S -- Process Status
The status of the task which can be one of:
'D' = uninterruptible sleep
'R' = running
'S' = sleeping
'T' = traced or stopped
'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

`D' は割り込み不可で典型的には I/O 待ち、らしい Processes in an Uninterruptible Sleep (D) State ディスク読み書き要求が多すぎるとか、スワップしてるとか、ネットワーク経由で読み書きしててリモートが遅いとか。

ところで、 http://unixhelp.ed.ac.uk/CGI/man-cgi はなかなか便利だ。 manpage をブラウザで閲覧できる。 JM Project (Japanese) のほうが(日本語なので)理解しやすいしぐぐってもこちらが出てくることが多いが、端末から man をひいたときはふつう英語のドキュメントが表示されるので、それと同じものがウェブにもあるとブログからリンクするときなどに便利だ(邦訳版だとページ内検索で探しづらい)この Man-cgi というスクリプト本体は Man-cgi home page で配布してるものらしい。