Linux进程的状态:task struct::state volatile long state;/-1 unrunnable,0 runnable,>0 stopped include/1inux/sched.h /Task state bitmask.NOTE!These bits are also encoded in fs/proc/array.c:get_task_state(). We have two separate sets of flags:task->state is about runnability,while task->exit_state are about the task exiting.Confusing,but this way modifying one set can't modify the other one by ◆mistake, #define TASK_RUNNING 0 #define TASK_INTERRUPTIBLE 1 state是按bit定义的 #define TASK_UNINTERRUPTIBLE 2 除TASK_RUNNING,其他都是状态位掩码 #define_TASK_STOPPED #define TASK_TRACED 当不处于其他任何状态时,即TASK RUNNING 8 in tsk->exit_state ' Linux:还定义了一些宏 #define EXIT_ZOMBIE 16 (1)一些组合状态 #define EXIT_DEAD 32 (2)关于状态的判断 /in tsk->state again (3)关于状态的设置 #define TASK_DEAD 64 #define TASK_WAKEKILL 128 东香兰(xlanchenoustc,edu.cn) (计算机应 Lu操作系分所Chapter D程管现 December 23.2014 8/95. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Linux进程的状态:task_struct::state volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ . include/linux/sched.h . . /* * Task state bitmask. NOTE! These bits are also * encoded in fs/proc/array.c: get_task_state(). * * We have two separate sets of flags: task->state * is about runnability, while task->exit_state are * about the task exiting. Confusing, but this way * modifying one set can’t modify the other one by * mistake. */ #define TASK_RUNNING 0 #define TASK_INTERRUPTIBLE 1 #define TASK_UNINTERRUPTIBLE 2 #define __TASK_STOPPED 4 #define __TASK_TRACED 8 /* in tsk->exit_state */ #define EXIT_ZOMBIE 16 #define EXIT_DEAD 32 /* in tsk->state again */ #define TASK_DEAD 64 #define TASK_WAKEKILL 128 state是按bit定义的 除TASK_RUNNING, 其他都是状态位掩码 当不处于其他任何状态时,即TASK_RUNNING Linux还定义了一些宏 (1)一些组合状态 (2)关于状态的判断 (3)关于状态的设置 陈香兰(xlanchen@ustc.edu.cn) (计算机应用教研室 Linux操作系统分析Chapter 9 进程管理 @计算机学院嵌入式系统实验室@苏州研究院中国科学技术大学Fall 2014) December 23, 2014 8 / 95