linux下的进程描述符task_struct
来源:互联网 发布:美工提升 编辑:程序博客网 时间:2024/05/23 20:27
一,数据结构
进程控制块PCB,是进程存在和运行的唯一标志,在linux中用task_struct这个结构体来表示。这个结构体中有许多数据项,查看源代码时没必要理解全部数据项,只需要在以后使用时在理解
struct task_struct{ ...}
下面重点介绍几个基本的数据项:
1.进程状态
task_struct中用长整形state表示进程的状态。
volatile long state;
在linux中有四种基本的进程状态:
(1)就绪态(TASK_RUNNING):包括了运行态的进程。这是为了方便管理,因为任意时刻处于就绪态的进程最多只有一个。
(2)等待态(睡眠态):有被分为两种
1.浅度睡眠态(TASK_INTERRUPTIBLE):在两种情况下被唤醒:①当等待的资源满足时。
②其他进程通过信号或时钟中断唤醒
2.深度睡眠态(TASK_UNTERRUPTIBLE):只能等到等待的资源满足时才被唤醒,而不能被其他进程唤醒.
(3)暂停态:收到以下几种信号,进程进入暂停状态:
ⅰ SIGSTOP ———-停止进程执行
ⅱSIGTSTP ———–从终端发来信号停止进程
ⅲSIGTTIN————来在键盘的中断
ⅳSIGTTOU———–后台进程请求输出
(4)僵尸状态(TASK_ZOMBIE):进程已结束且释放大部分资源,但尚未释放其PCB。
2.进程标识符
Linux用一个32 位无符号整形pid来简单标识一个进程,用uid和gid分别来标识进程所属的用户和组
pid_t pid;uid_t uid;gid_t gid;
pid的上限是由pid_max决定的。编译内核时会让选择0x1000和0x8000两种数值,即pid_max=4096和pid_max=32768两种。
3.亲属关系
struct list_head children; //子进程链表struct list_head sibling; //兄弟进程链表struct task_struct *real_parent; //真正创建当前进程的进程struct task_struct *parent; //养父进程
二、进程控制块的存放
1、内存栈
当进程从用户态进入内核态时要使用位于内核数据段上的内核栈,
2,数据结构
union thread_union{ struct thread_info thread_info; unsigned long stack[THERAD_SIZE/sizeof(long)];//内存栈,一般为8kb};
内核中将task_struct的指针放在thread_info结构体中,而这个结构体又与内核栈一块被放在8kb 的内核空间thread_union中。
struct thread_info{ struct task_struct * task; struct exec_domain *exec_domain;}
- linux下的进程描述符task_struct
- linux下的进程描述符——task_struct
- linux下的进程描述符task_struct 结构体认识
- Linux进程描述符task_struct
- Linux下进程及其描述task_struct
- 【Linux】 进程PCB的描述(task_struct)
- linux进程描述符task_struct详解
- linux进程描述符task_struct详解
- linux进程描述符—task_struct结构
- 详解Linux中的进程描述符task_struct
- linux进程描述符task_struct详解
- 详解Linux中的进程描述符task_struct
- Linux进程描述符:task_struct结构体
- Linux进程描述符task_struct结构体
- Linux 进程描述符task_struct详解
- Linux进程描述符:task_struct结构体
- 详解Linux中的进程描述符Task_struct
- Linux进程描述符task_struct结构体简析
- 应用程序安装时出现2个相同的图标
- 栈
- Dynamics CRM2016 Web Api Filter查询中的特殊字符串处理
- MATLAB快捷键
- Ubuntu安装intel集显驱动
- linux下的进程描述符task_struct
- android 中遇到的空指针异常
- 数值实验分段函数图像-Python绘图
- python3面向对象编程一(类)
- java通过ip获取网卡MAC地址
- 关爱自身健康,自身健康才是硬实力
- php mbstring扩展概要
- 【神经网络与深度学习】【计算机视觉】SSD
- 数据分析和数据可视化(第一讲)