操作系统理论中的进程状态与 Linux 中的进程状态

火车寿司

我正在尝试将 Linux 进程状态代码(如ps映射到操作系统状态图中的状态,但我似乎无法映射它们。是不是因为 Linux 进程状态不一定与理论上的 OS 状态图匹配?具体地讲,我不确定其中D/ S/ T/I配合的图中

  • ps来自手册页的进程状态代码

    PROCESS STATE CODES
           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)
                   I    Idle kernel thread
                   R    running or runnable (on run queue)
                   S    interruptible sleep (waiting for an event to
                        complete)
                   T    stopped by job control signal
                   t    stopped by debugger during the tracing
                   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 parent
    
  • 来自维基百科的操作系统进程状态图

    操作系统进程状态图

类似于“停止”是否属于“阻塞”状态?但答案很不完整。

CG909

简短的回答:

各州(大致)映射如下:

状态 意义
D 被封锁
I 被封锁
R Waiting or Running
S Blocked
T Blocked (more or less)
t Blocked (more or less)
W Blocked (obsolete since Linux 1.1.30)
X Terminated
Z Terminated

Long answer:

The externally visible process state codes in Linux try to pack information that might be interesting for a system administrator into one character, so they also include information why a process is blocked (and thus if it can be unblocked and what may unblock it).

The distinction between "Waiting" and "Running" is blurred, because processes run in such tiny time slices that, for a human sitting in front of the computer, there is not much difference between a process ready to run and a process running.

Also Linux doesn't swap out whole processes but individual memory pages, so you won't find states mapping to "Swapped out and waiting" or "Swapped out and blocked".

State Meaning
D The process is blocked and that state cannot be interrupted (e.g. with kill). Usually while in this state the kernel is performing I/O on behalf of the process, and the kernel code in question isn't able to handle interruptions.
I The process is a kernel thread that currently has nothing to do and is blocked waiting for new work. This state is technically the same as D (as usually kernel threads aren't interruptible). It was introduced for accounting/cosmetic reasons, because processes in D state are considered contributing to the system load.
R The process is waiting to run or running. These are all processes the scheduler can and will schedule on the available CPUs. Internally the kernel can differentiate between running and waiting processes but this isn't exposed through the process state codes.
S The process is blocked and that state can be interrupted with kill. This state is entered with most system calls that wait for some event (sleep, select, poll, wait, etc.).
T The process is blocked from being scheduled by a signal like SIGSTOP. This state doesn't match perfectly into the theoretical state "Blocked" because the process doesn't wait for an event by itself, but is usually blocked from further running by intervention of another process or the user (Ctrl+Z).
t Similar to above. The process is blocked from being scheduled by a debugger or tracing process, not by itself waiting for an event.
W 过时的。该进程被阻塞,等待将内存页从交换区读取到 RAM 中。这段代码一直使用到 Linux v1.1.30从 v2.3.43 开始,无法再将进程置于此状态,并且从 v2.5.50 开始,对这种状态的每个引用都已删除。
X 进程终止,当前正在从进程列表中删除。您不会经常看到这种状态,因为它只ps在内核清理另一个 CPU 内核上的进程条目的瞬间运行时才会出现
Z 进程终止,进程列表中的条目仅存在,以便父进程可以收集退出状态信息。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

操作系统中的进程状态和资源利用

来自分类Dev

Linux上的进程状态

来自分类Dev

Linux上的进程状态

来自分类Dev

如何在Linux中显示进程状态(阻塞,非阻塞)

来自分类Dev

在Linux中如何使进程处于T(跟踪)状态?

来自分类Dev

操作系统中的进程表

来自分类Dev

在Linux / C ++中,发送到线程/进程的信号是否使其变为活动状态?

来自分类Dev

如何将进程状态从睡眠更改为在Linux中运行?

来自分类Dev

Linux中的线程进程

来自分类Dev

Fedora Linux 中的进程

来自分类Dev

核心转储时Linux进程的状态

来自分类Dev

如何检查进程是否是Linux中的系统进程?

来自分类Dev

操作系统中进程运行状态和执行状态的区别

来自分类Dev

我如何在Linux操作系统上使用clock_getttime()在C中以纳秒为单位记录进程执行时间?

来自分类Dev

在Python中运行bash命令:操作系统与子进程?

来自分类Dev

操作系统中的进程和线程调度

来自分类Dev

操作系统中的进程和线程类型是什么?

来自分类Dev

在bash中获取进程的退出状态

来自分类Dev

进程终止,状态为C中的-1073741819

来自分类Dev

进程终止,状态为-1073741819中循环?

来自分类Dev

如何从python代码中获取进程状态?

来自分类Dev

什么是Linux中的匿名进程?

来自分类Dev

Linux:操作系统支持无特权的进程间总线

来自分类Dev

进程被 Linux 操作系统杀死 - 没有 OOM 登录 /var/log 文件

来自分类Dev

在 Linux 操作系统 XAMPP 或 LAMP 中安装什么?

来自分类Dev

如何在Stopped状态下派生Linux进程?

来自分类Dev

隐藏来宾操作系统中的虚拟机状态

来自分类Dev

进程读取文件后,删除Linux系统中的文件

来自分类Dev

进程如何尝试访问Linux虚拟内存系统中其他进程的内存

Related 相关文章

  1. 1

    操作系统中的进程状态和资源利用

  2. 2

    Linux上的进程状态

  3. 3

    Linux上的进程状态

  4. 4

    如何在Linux中显示进程状态(阻塞,非阻塞)

  5. 5

    在Linux中如何使进程处于T(跟踪)状态?

  6. 6

    操作系统中的进程表

  7. 7

    在Linux / C ++中,发送到线程/进程的信号是否使其变为活动状态?

  8. 8

    如何将进程状态从睡眠更改为在Linux中运行?

  9. 9

    Linux中的线程进程

  10. 10

    Fedora Linux 中的进程

  11. 11

    核心转储时Linux进程的状态

  12. 12

    如何检查进程是否是Linux中的系统进程?

  13. 13

    操作系统中进程运行状态和执行状态的区别

  14. 14

    我如何在Linux操作系统上使用clock_getttime()在C中以纳秒为单位记录进程执行时间?

  15. 15

    在Python中运行bash命令:操作系统与子进程?

  16. 16

    操作系统中的进程和线程调度

  17. 17

    操作系统中的进程和线程类型是什么?

  18. 18

    在bash中获取进程的退出状态

  19. 19

    进程终止,状态为C中的-1073741819

  20. 20

    进程终止,状态为-1073741819中循环?

  21. 21

    如何从python代码中获取进程状态?

  22. 22

    什么是Linux中的匿名进程?

  23. 23

    Linux:操作系统支持无特权的进程间总线

  24. 24

    进程被 Linux 操作系统杀死 - 没有 OOM 登录 /var/log 文件

  25. 25

    在 Linux 操作系统 XAMPP 或 LAMP 中安装什么?

  26. 26

    如何在Stopped状态下派生Linux进程?

  27. 27

    隐藏来宾操作系统中的虚拟机状态

  28. 28

    进程读取文件后,删除Linux系统中的文件

  29. 29

    进程如何尝试访问Linux虚拟内存系统中其他进程的内存

热门标签

归档