1. 举例
从终端shell命令行启动一个图形界面的程序(用xlogo来举例)
然后在再切换到该终端,可以按Ctrl-Z(信号为:SIG,信号编号:19,名称为:CONT)暂停该图形程序,可以看到该图形程序窗口内部没有正常显示了,表示该进程处于暂停状态,进程内核状态为:TASK_STOPPED(TASK_STOPPED: process stopped by a debugger or job control)
Ctl-Z后终端显示:
[1]+ 已停止 xlogo # 1 是任务号,可以通过:fg %1 重新令该程序在前台运行
# ps aux | grep xlogo
10018 0.0 0.0 6124 1792 pts/1 T 16:49 0:00 xlogo # T表示暂停状态,可以通过:kill -s CONT 10018 另xlogo在后台运行
参考:The Linux Command Line, chapter 11
2. TASK_STOPPED
2.4内核:信号或者ptrace可以造成进程进入TASK_STOPPED
2.6内核:ptrace造成的进程暂停(很多书直接用STOPPED,也用用pause的,这里用暂停表示该进程之后还可以继续运行)进入TASK_TRACED状态,信号造成的进程暂停/停止;
Understanding Linux Kernel, 3rd, 3.2 Precess Descriptor:
TASK_STOPPED
Process execution has been stopped; the process enters this state after receiving a SIGSTOP, SIGTSTP, SIGTTIN, or SIGTTOU signal.
TASK_TRACED
Process execution has been stopped by a debugger. When a process is being monitored by another (such as when a debugger executes a ptrace( ) system call to monitor a test program), each signal may put the process in the TASK_TRACED state.
有个疑问:那么处于TASK_STOPPED状态的进程,在什么队列呢?
在statckoverflow.com询问得到解答:TASK_STOPPED还是处于runqueue,只是标记了TASK_STOPPED的进程,调度器不会选择他们执行。
http://stackoverflow.com/questions/9719853/which-queue-dos-a-paused-process-resident