操作系统原理介绍的进程状态:
- TASK_RUNNING”:运行
- “TASK_INTERRUPTIBLE”:任务可中断
- “TASK_UNINTERRUPTIBLE”:任务不可中断
- “__TASK_STOPPED”:停止
- “__TASK_TRACED”:
源码中,进程的状态定义位于./include/linux/sched.h中:
#define TASK_RUNNING 0
#define TASK_INTERRUPTIBLE 1
#define TASK_UNINTERRUPTIBLE 2
#define __TASK_STOPPED 4 进程的执行被暂停,当进程接收到SIGSTOP、SIGTSTP、SIGTTIN、SIGTTOU信号后,进入暂停状态
#define __TASK_TRACED 8
/* in tsk->exit_state */
#define EXIT_DEAD 16
#define EXIT_ZOMBIE 32
#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD)
/* in tsk->state again */
#define TASK_DEAD 64
#define TASK_WAKEKILL 128
#define TASK_WAKING 256
#define TASK_PARKED 512
#define TASK_STATE_MAX 1024
PS命令显示的进程状态
D uninterruptible sleep (usually IO) //不可中断睡眠
R running or runnable (on run queue) //正在执行或可执行
S interruptible sleep (waiting for an event to complete) //可中断睡眠状态
T stopped, either by a job control signal or because it is being traced //停止或追踪状态
W paging (not valid since the 2.6.xx kernel) //换页,但2.6之后内核已不再可用
X dead (should never be seen) //死亡,但应该永远也看不到
Z defunct ("zombie") process, terminated but not reaped by its parent //僵死状态(已经终止但还没有被父进程回收)
进程状态切换图