| 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_RUNNING | 0 | ||||||||||
| #define TASK_INTERRUPTIBLE | 1 | ||||||||||
| #define TASK_UNINTERRUPTIBLE | 2 | ||||||||||
| #define TASK_STOPPED | 4 | ||||||||||
| #define TASK_ZOMBIE | 8 | ||||||||||
| #define TASK_DEAD | 16 | ||||||||||
| 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_info | task_struct | |||||||||
| andl %esp,%ecx | |||||||||||
| movl %ecx,p | kernel 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 | |||||||||||
| : | |||||||||||
Understand the linux kernel-ch3-Process descriptor
最新推荐文章于 2024-10-31 18:07:11 发布
3642

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



