Understanding the linux kernel-ch3-Process descriptor

 The process list
init_task//i386/kernel/init_task.c
struct task_struct init_task = INIT_TASK(init_task);
REMOVE_LINKSinclude/linux/sched.h
SET_LINKS
#define REMOVE_LINKS(p) do {/
if (thread_group_leader(p))/
list_del_init(&(p)->tasks);/
remove_parent(p);/
} while (0)
#define SET_LINKS(p) do {/
if (thread_group_leader(p))/
list_add_tail(&(p)->tasks,&init_task.tasks);/
add_parent(p, (p)->parent);/
} while (0)
for_each_process
#define for_each_process(p) /
for (p = &init_task ; (p = next_task(p)) != &init_task ; )
The lists of TASK_RUNNING processes
run_list of task_struct
array of task_struct
Relationships Among Processes
real_parent of task_struct
parent of task_struct
children of task_struct
sibling of task_struct
group_leader of task_struct
tgid
The pidhash table and chained lists
four hash tables 
because the process descriptor includes fields that represent different types of PID 
How Processes Are Organized
TASK_STOPPED, EXIT_ZOMBIE, or EXIT_DEAD state are not linked 
TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE state are 
subdivided into many classes, each of which corresponds to a specific event
wait_queue_head_t//include/linux/wait.h
struct _ _wait_queue_head {
        spinlock_t lock;
        struct list_head task_list;
    };
Element
struct __wait_queue {
unsigned int flags;
struct task_struct * task;
wait_queue_func_t func;
struct list_head task_list;
};
我就像内核中等待队列中的一个要素。处在睡眠中,在等待某个事件的出现,把我唤醒。
但是就算个事件出了,被醒的也不一定是我,因我不一定列的前
exclusive processes flags == 1排他
exclusive processes flags == 0非排他
Handling wait queues
DECLARE_WAIT_QUEUE_HEAD(name)
init_waitqueue_head( )
init_waitqueue_entry(q,p )
default_wake_function( )
:
void sleep_on(wait_queue_head_t *q)//kernel/sched.c
void interruptible_sleep_on(wait_queue_head_t *q)
long interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
long sleep_on_timeout(wait_queue_head_t *q, long timeout)
//kernel/fork.c
void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)
void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
wake_up
Process Resource Limits//include/linux/resource.h
struct rlimit {
unsigned longrlim_cur;
unsigned longrlim_max;
};
RLIM_INFINITY (0xffffffff)
/*
 * Resource limits
 */
#define RLIMIT_CPU0/* CPU time in ms */
#define RLIMIT_FSIZE1/* Maximum filesize */
#define RLIMIT_DATA2/* max data size */
#define RLIMIT_STACK3/* max stack size */
#define RLIMIT_CORE4/* max core file size */
#define RLIMIT_RSS5/* max resident set size */
#define RLIMIT_NPROC6/* max number of processes */
#define RLIMIT_NOFILE7/* max number of open files */
#define RLIMIT_MEMLOCK8/* max locked-in-memory address space */
#define RLIMIT_AS9/* address space limit */
#define RLIMIT_LOCKS10/* maximum file locks held */
#define RLIM_NLIMITS11      
          

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值