您的位置:首页 > 运维架构 > Linux

Understand the linux kernel-ch3-Process descriptor

2008-06-19 21:39 381 查看
Chapter 3. Processes
a process is an instance of a program in execution
From the kernel's point of view, the purpose of a process is to act
as an entity to which system resources (CPU time, memory, etc.) are allocated
lightweight processes to offer better support for multithreaded applications
Process Descriptor
task_struct
Process State
#define TASK_RUNNING0
#define TASK_INTERRUPTIBLE1
#define TASK_UNINTERRUPTIBLE2
#define TASK_STOPPED4
#define TASK_ZOMBIE8
#define TASK_DEAD16
EXIT_ZOMBIE
EXIT_DEAD
set_task_state
set_current_state
Identifying a Process
PID
tgid
Process descriptors handling
task
movl $0xffffe000,%ecx /* or 0xfffff000 for 4KB stacks */thread_infotask_struct
andl %esp,%ecx 
movl %ecx,pkernel stack
 
esp
current macro//current.h
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
__asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~8191UL));
return ti;
}
static inline struct task_struct * get_current(void)
{
return current_thread_info()->task;
}
#define current get_current()
Doubly linked lists
LIST_HEAD_INIT//include/linux/list.h
LIST_HEAD
INIT_LIST_HEAD
HLIST_HEAD_INIT
HLIST_HEAD
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: