PCB进程控制块

来源:互联网 发布:fanuc编程 编辑:程序博客网 时间:2024/05/17 07:30
include/linux/sched.hstruct 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 task_struct *real_parent;struct task_struct *parent;struct list_head children; struct list_head sibling; struct task_struct *group_leader;... struct pid_link pids[PIDTYPE_MAX];  wait_queue_head_t wait_chldexit; struct completion *vfork_done; int __user *set_child_tid; int __user *clear_child_tid;  unsigned long rt_priority; unsigned long it_real_value, it_prof_value, it_virt_value; unsigned long it_real_incr, it_prof_incr, it_virt_incr; struct timer_list real_timer; unsigned long utime, stime, cutime, cstime; unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; u64 start_time;... uid_t uid,euid,suid,fsuid;  gid_t gid,egid,sgid,fsgid; struct group_info *group_info; kernel_cap_t cap_effective, cap_inheritable, cap_permitted; int keep_capabilities:1; struct user_struct *user;... struct rlimit rlim[RLIM_NLIMITS]; unsigned short used_math; char comm[16];... int link_count, total_link_count;... struct fs_struct *fs;... struct files_struct *files;... unsigned long ptrace_message; siginfo_t *last_siginfo;... };



调度数据成员:
1) vo latile long state
表示进程的当前状态。进程运行时, 它会根据具体情况改变状态。进程状态总共有TASK RUNN ING ( 可运行状态)、TASK INTERRUPT IBLE ( 可中断的等待状态)、TASK UNINTERRUPT IBLE(不可中断的等待状态)、TASK ZOMB IE( 僵死状态)、TASK STOPPED(暂停状态) 等5种。
2) long pr io rity进程优先级, prio rity 的值给出了进程每次获取CPU 后, 可使用的时间片长度( 单位是jiffies)。
3) unsigned long rt_priority rt_priority 的值给出了实时进程的优先级, rt_priority 
1000给出进程每次获取CPU 后, 可使用的时间片长度(单位是jiffies)。
4) long counter在轮转法调度时counter表示当前进程还可运行多久。在进程开始时被赋为priority的值, 以后每隔一个时钟中断递减1,减到0时引起新一轮调度。
5) unsigned long policy表示该进程的进程调度策略。调度策略有:
SCH ED_OTHER 0, 非实时进程, 用基于优先权的轮转法。
SCH ED_FIFO 1, 实时进程, 用先进先出算法。
SCH ED_RR 2, 实时进程, 用基于优先权的轮转法
 
进程队列指针:
1) struc t task_struct* next_task, * prev_task
在Linux 中所有进程(以PCB 的形式)组成一个双向链表,
next_task和prev_task是链表的前后向指针。
2) struct task_struct* p_opptr, * p_pptr
struct task_struc t* p_cptr, * p_ysptr, * p_osptr
以上分别是指向该进程的原始父进程、父进程、子进程和新
老兄弟进程的指针。
3) struct task_struct* pidhash_next
struct task_struct** pidhash_pprev
用于链入进程hash表的前后指针。系统进程除了链入双
向链表外, 还被加到hash表中。
 
进程标识:
uid_t uid  gid_t gid uid和gid分别是运行进程的用
户标识和用户组标识。
pid_t pid  pid_t pgrp pid和pgrp分别是运行进程的
进程标识号和进程组标识号
时间数据成员:
long per_cpu_utime [ NR_CPUS ] per_cpu_stime
[ NR_CPUS]
per_cpu_utime 是用户态进程运行的时间, per_cpu_
stime是内核态进程运行的时间
进程创建时间unsigned long start_time


文件系统数据成员:
struct fs_struct* fs
fs保存了进程本身与VFS( 虚拟文件系统)的关系信息。
struct fs_struct
{
 atom ic_t count;
 rw lock_t lock;
 int umask;
 struct dentry* root, * pwd, * altroot;
 struct vfsm ount* rootmnt, * pwdmnt, * altrootmnt;
}
其中root、rootm nt是根目录的dentry 和其mount点的vfsmount。
pwd、pwdmnt 是当前工作目录的dentry 和其mount 点的vfs..
mount。altroot、altrootmnt是保存根节点被替换之后原来根目标
的dentry和其mount点的vfsmount。
 
内存数据成员:
1) struct mm_struct* mm
在Linux 中, 采用按需分页的策略解决进程的内存需求。
task_struct的数据成员mm 指向关于存储管理的mm_truc t结
构。
2) struct mm_struct* active_mm
active_mm 指向活动地址空间。
3) mm_segm ent_t addr_ lim it
表示线程空间地址。
用户线程空间地址: 0..0xBFFFFFFF。
内核线程空间地址: 0..0xFFFFFFFF
4) spinlock_t alloc_ lock
用于申请空间时用的自旋锁。自旋锁的主要功能是临界区
保护。
 
页面管理:
1) int swappable: 1
进程占用的页面是否可换出。swappab le为1表示可换出。
2) unsigned long min_flt, maj_ flt
该进程累计minor缺页次数和major缺页次数。
3) unsigned long nswap
该进程累计换出页面数。
4) unsigned long swap_cnt
下一次循环最多可换出的页数。

阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 好字多少笔画 21天写一手好字 好字甲骨文 京东中华好字成 四字书法作品 钢笔字模板 描字帖能练好字吗 一手好字图片 如何写一笔好字 成人钢笔字速成 30岁怎么练好字 钢笔字书写技巧 大人怎么练好字 20天写一手好字 钢笔字楷体字帖 与字 向字 20字的好句 打好字 啊字 有日字旁的字 三点水的好字 字旁的字 好字不如烂画 好字的拼音 好字几笔画 怎么练一笔好字 把字 沿字 钢笔字书法作品 练钢笔字字帖 或字 得字 怎样写一笔好字 字什么 好字有几画 连一手好字 且字 古寿字 练一笔好字 好字先从殿里来