3.2.2.4. The process list
来源:互联网 发布:淘宝买lol号卖家不给 编辑:程序博客网 时间:2024/06/09 13:38
3.2.2.4. The process list
The first example of a doubly linked list we will examine is theprocess list, a list that links together all existing process descriptors. Each task_struct structure includes a tasks field of type list_head whose prev and next fields point, respectively, to the previous and to the next task_struct element.
The head of the process list is the init_task task_struct descriptor; it is the process descriptor of the so-calledprocess 0 orswapper (see the section "Kernel Threads" later in this chapter). The tasks->prev field of init_task points to the tasks field of the process descriptor inserted last in the list.
The SET_LINKS and REMOVE_LINKS macros are used to insert and to remove a process descriptor in the process list, respectively. These macros also take care of the parenthood relationship of the process (see the section "How Processes Are Organized" later in this chapter).
Another useful macro, called for_each_process, scans the whole process list. It is defined as:
#define for_each_process(p) \ for (p=&init_task; (p=list_entry((p)->tasks.next, \ struct task_struct, tasks) \ ) != &init_task; )
The macro is the loop control statement after which the kernel programmer supplies the loop. Notice how the init_task process descriptor just plays the role of list header.The macro starts by moving past init_task to the next task and continues until it reaches init_task again (thanks to the circularity of the list).At each iteration, the variable passed as the argument of the macro contains the address of the currently scanned process descriptor, as returned by the list_entry macro.
这个宏从经过init_task开始,把指针移到下一个任务,然后继续,直到再次遇到init_task为止- 3.2.2.4. The process list
- The C# Design Process
- The Linux Process Manager
- The Inspection Process
- The process of testing
- The C# Design Process
- The Linux Process Manager
- The Kernel Boot Process
- The Linux Boot Process
- The Android boot process
- The ClientLogin authorization process
- The Kernel Boot Process
- The birth-death process
- The Kernel Boot Process
- The Kernel Boot Process
- The Process Of BFS.
- The Kernel Boot Process
- Examining the Compilation Process
- C#调用shutdown 来关机
- Delphi DBGRID中 根据不同的字段值显示不同的小图标
- httpclient介绍
- [观点]是重构,还是代码修整?
- bash编程系列-环境变量
- 3.2.2.4. The process list
- MoveWindow和setwindowpos的区别
- Java模式之动态代理
- (已测试)C# web下文件下载方法
- Linux基础知识及常用命令
- 面试总结1
- 对java 同步synchronized 的理解
- 手动清除jwgkvsq.vmx病毒
- 一个操作系统的实现---内核雏形