In linux, what do all the values in the “top” command mean?

后端 未结 3 398
天涯浪人
天涯浪人 2021-01-31 01:57

When you run \"top\" and see all running processes, I\'ve always wanted to know just what everything actually means. e.g. all the various single-letter state codes for a runnin

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 02:26

    The man page says what the state codes are mapped to, but not what they actually mean. From the top man page:

    'D' = uninterruptible sleep
    'R' = running
    'S' = sleeping
    'T' = traced or stopped
    'Z' = zombie
    

    'R' is the easiest; the process is ready to run, and will run whenever its turn to use the CPU comes.

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

    'Z' is a state where the process is dead (it has finished its execution), and the only thing left is the structure describing it on the kernel. It is waiting for its parent process to retrieve its exit code, and not much more. After its parent process is finished with it, it will disappear.

提交回复
热议问题