查看方式
top命令
top命令中S
那一列。即下图中SHR
后面%CPU
前面那一列。下图中的sshd进程和systemd进程的S
列都处于S
状态
1 | $top |
ps命令
ps命令中STAT
那一列。下图中systemd进程为Ss
,[kthreadd]为S
。
1 | $ps aux |
含义
top
文档中的描述
1 | 3a. DESCRIPTIONS of Fields |
ps
文档中的描述
1 | PROCESS STATE CODES |
资料
In linux, what do all the values in the “top” command mean? - Stack Overflow - answered by CesarB
‘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.
Linux Process States - Stack Overflow - answered by zerodeux
S
状态
大部分空闲时的进程都处于该状态。
D
状态
linux - What is an uninterruptable process? - Stack Overflow - answered by CesarB
Uninterruptable processes are USUALLY waiting for I/O following a page fault.
Consider this:
- 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.
D
状态,为了保护进程数据与硬件状态一致,可看为是系统对进程和硬件设备的保护机制。正常情况下,D状态持续时间很短,一般可以忽略。如果出现大量D状态,需要关注是否io性能出现问题。
其他参考链接
- ps – report process status - 煎鸡蛋汤 - CSDN博客
- linux学习笔记27–监控命令ps和top,free - gaomatlab - 博客园
- 【Linux】ps(process status)命令 - Alice_Bob的博客 - CSDN博客
本文完,作者yoko,尊重劳动人民成果,转载请注明原文出处: https://pengrl.com/p/21094/