一、进程控制块(PCB)结构
进程控制块(PCB)是系统为了管理进程设置的一个专门的数据结构。系统用它来记录进程的外部特征,描述进程的运动变化过程。同时,系统可以利用PCB来控制和管理进程,所以说,PCB(进程控制块)是系统感知进程存在的唯一标志。
Linux系统的PCB包括很多参数,每个PCB约占1KB多的内存空间。用于表示PCB的结构task_struct简要描述如下:
include/linux/sched.h
struct task_struct {
volatile long state;
struct thread_info *thread_info;
atomic_t usage;
unsigned long flags;
unsigned long ptrace;
int lock_depth;
int prio, static_prio;
struct list_head run_list;
prio_array_t *array;
unsigned long sleep_avg;
long interactive_credit;
unsigned long long timestamp;
int activated;
unsigned long policy;
cpumask_t cpus_allowed;
unsigned int time_slice, first_time_slice;
struct list_head tasks;
struct list_head ptrace_children;
struct list_head ptrace_list;
struct mm_struct *mm, *active_mm;
...
struct linux_binfmt *binfmt;
int exit_code, exit_signal;
int pdeath_signal;
...
pid_t pid;
pid_t tgid;
...
struct

本文详细介绍了Linux系统中进程控制块(PCB)的结构,包括调度数据成员如进程状态、优先级、时间片等,进程队列指针,进程标识,时间数据成员,文件系统数据成员以及内存数据成员等。同时提到了makefile在编译过程中的作用和基本规则。
最低0.47元/天 解锁文章

1439

被折叠的 条评论
为什么被折叠?



