前言 大家好吖,欢迎来到 YY 滴Linux系列 ,热烈欢迎! 本章主要内容面向接触过Linux的老铁 主要内容含:
PS:我们大致知道就可以,理解在下文
引入: 下面以Linux操作系统中的状态举例,不同系统或多或少会有差别
原理:
#define NEW 1
#define RUNNING 2
#define BLOCK 3
PCB->status == BLOCK
if(PCB->status == NEW) //PCB放入运行队列
else if (PCB->status == BLOCK) //PCB放入阻塞队列
重点
/*
* The task state array is a strange "bitmap" of
* reasons to sleep. Thus "running" is zero, and
* you can test for combinations of others with
* simple bit tests.
*/
static const char * const task_state_array[] = {
"R (running)", /* 0 */
"S (sleeping)", /* 1 */
"D (disk sleep)", /* 2 */
"T (stopped)", /* 4 */
"t (tracing stop)", /* 8 */
"X (dead)", /* 16 */
"Z (zombie)", /* 32 */
};
#define SIGKILL 9
kill -SIGSTOP [PID] //PID对应进程由S状态进入T状态,前台进程变为后台进程
kill -SIGCONT [PID] //PID对应进程由T状态进入S状态,后台进程变为前台进程