- linux的进程控制块是一个有结构task_struct所定义的数据结构,task_struct存放在/index/linux/sched.h中,包括管理进程的所需的各种信息。
- 在创建一个新进程时,系统在内存中申请一个空的task_struct区,即空闲PCB块,并填入所需信息,同时将指向该结构的指针填入到task[]数组中。
- 当前处于运行状态进程的PCB用指针数组current_set[]来指出,这是因为Linux支持多处理系统,系统内可能存在多个同时运行的程序。
- Linux系统的PCB包括很多参数,每个PCB约占1KB的内存空间,用于表示PCB的结构task_struct简要描述如下:
struct task_struct
{
unsigned short uid;
int pid;
int processor;
volatile long state;
long prority;
unsigned long rt_prority;
long counter;
unsigned long flags;
unsigned long policy;
struct task_struct * next_task,*prev_task;
struct task_struct * next_run,*prev_run;
struct task_struct * p_opptr,*p_pptr,*p_cptr,*pysptr,*p_ptr;
}
- volatile long state;//标识进程的状态,可为下列6种状态之一:
1)可运行状态TASK_RUNING
2)可中断阻塞状态TASK_UBERRUPTIBLE
3)不可中断阻断状态TASK_UNINTERRUPTIBLE
4)僵死状态TASK_STOPPED
5)暂停态TASK_STOPPED
6)交换态TASK_SWAPPING