如何将Linux进程状态分类为running,runnable,not runnable或invalid?

时间:2012-04-10 19:04:35

标签: linux process

我需要对以下过程状态进行分类(从/ proc / [PID] / status获得)

  • R(跑步)
  • S(睡觉)
  • D(磁盘睡眠)
  • T(停止)
  • T(追踪止损)
  • Z(僵尸)
  • X(死)

作为

  • 跑步(1),
  • runnable(2), - 等待资源(CPU,内存,IO)
  • 不可运行(3), - 已加载但等待事件
  • 无效(4) - 未加载

我最初的猜测:

1:R (running)
2:S (sleeping)
3:D (disk sleep)
3:T (stopped)
3:T (tracing stop)
4:Z (zombie)
4:X (dead)

这是对的吗?

1 个答案:

答案 0 :(得分:2)

来自fs / proc / array.c:

static const char * const task_state_array[] = {
        "R (running)",          /*   0 */
        "S (sleeping)",         /*   1 */
        "D (disk sleep)",       /*   2 */
        "T (stopped)",          /*   4 */
        "t (tracing stop)",     /*   8 */
        "Z (zombie)",           /*  16 */
        "X (dead)",             /*  32 */
        "x (dead)",             /*  64 */
        "K (wakekill)",         /* 128 */       
        "W (waking)",           /* 256 */
};