在 Linux 中,“top”中的所有值有何作用? 命令是什么意思?

发布于 2024-07-09 09:12:39 字数 127 浏览 6 评论 0原文

当您运行 top 并查看所有正在运行的进程时,我一直想知道所有内容的实际含义。 例如,正在运行的进程的所有各种单字母状态代码(R = 正在运行,S = 正在睡眠,等等...)

我在哪里可以找到它?

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 running process (R = Running, S = Sleeping, etc...)

Where can I find this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

漫雪独思 2024-07-16 09:12:39

手册页说明了状态代码映射到的内容,但不是它们的实际含义。 从 top 手册页来看:

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

“R”是最简单的; 该进程已准备好运行,并且每当轮到使用 CPU 时就会运行。

“S”和“D”是两种睡眠状态,进程正在等待某些事情发生。 不同的是'S'可以被信号中断,而'D'则不能(通常在进程等待磁盘时看到)。

“T”是进程停止的状态,通常通过 SIGSTOPSIGTSTP 进行。 它也可以由调试器 (ptrace) 停止。 当您看到该状态时,通常是因为您使用 Ctrl+ Z 将命令放在背景上。

“Z”是进程死亡(它已完成执行)的状态,唯一剩下的是内核上描述它的结构。 它正在等待其父进程检索其退出代码,仅此而已。 当它的父进程处理完它之后,它就会消失。

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.

旧竹 2024-07-16 09:12:39

您可以使用命令 man top< /a> 查找状态:

D = uninterruptible sleep
I = idle
R = running
S = sleeping
T = stopped by job control signal
t = stopped by debugger during trace
Z = zombie

You can use the command man top to look up the states:

D = uninterruptible sleep
I = idle
R = running
S = sleeping
T = stopped by job control signal
t = stopped by debugger during trace
Z = zombie
尸血腥色 2024-07-16 09:12:39

topps 等程序从内核本身获取这些值。 您可以在此处的源代码中找到其定义:

https://github.com/torvalds/linux/blob/3950e975431bc914f7e81b8f2a2dbdf2064acb0f/fs/proc/array.c#L129-L143

static const char * const task_state_array[] = {

    /* states in TASK_REPORT: */
    "R (running)",      /* 0x00 */
    "S (sleeping)",     /* 0x01 */
    "D (disk sleep)",   /* 0x02 */
    "T (stopped)",      /* 0x04 */
    "t (tracing stop)", /* 0x08 */
    "X (dead)",     /* 0x10 */
    "Z (zombie)",       /* 0x20 */
    "P (parked)",       /* 0x40 */

    /* states beyond TASK_REPORT: */
    "I (idle)",     /* 0x80 */
};

有关更多信息,请参阅此问题:https://unix.stackexchange.com/q/462098/79648

Programs like top and ps takes these values from the kernel itself. You can find its definitions in the source code here:

https://github.com/torvalds/linux/blob/3950e975431bc914f7e81b8f2a2dbdf2064acb0f/fs/proc/array.c#L129-L143

static const char * const task_state_array[] = {

    /* states in TASK_REPORT: */
    "R (running)",      /* 0x00 */
    "S (sleeping)",     /* 0x01 */
    "D (disk sleep)",   /* 0x02 */
    "T (stopped)",      /* 0x04 */
    "t (tracing stop)", /* 0x08 */
    "X (dead)",     /* 0x10 */
    "Z (zombie)",       /* 0x20 */
    "P (parked)",       /* 0x40 */

    /* states beyond TASK_REPORT: */
    "I (idle)",     /* 0x80 */
};

For more info see this question: https://unix.stackexchange.com/q/462098/79648

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文