ULK --- Chap3 Processes: Doubly linked lists

Before moving to and describing how the kernel keeps track of the various processes in the system,

we would like to emphasize the role of special data structures that implement doubly linked lists.

For each list, a set of primitives operations must be implemented: initializing the lists, inserting and

deleting an element, scanning the list, and so on. It would be both a waste of programmers' effort

and a waste of memory to replicate the primitive operations for each different list.

Therefore, the Linux kernel defines the list_head data structure, whose only fields next and prev 

represent the forward and back pointers of a generic doubly linked list element, respectively. It is

important to note, however, that the pointers in a list_head field store the addresses of other list_heads

rather then the addresses of the whole data structure in which the list_head structure is included;

A new list is created by using the LIST_HEAD(list_name) macro. It declares a new variable named

list_name of  type list_head, which is a dummy first element that acts as a placeholder for the head

of the new list, and initializes the prev and next fields of the list_head data structure so as to point

to the list_name variable itself.

                         The Process List

The first example of a doubly linked list we will examine is the process 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-called process 0 or swapper. The task->prev field of init_task points to the tasks field of the process

descriptor inserted last in the list.

The SET_LINK and REMOVE_LINK 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.

Another useful macro, called for_each_process, scans the whole process list. It is defined as follows.

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 interation, 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.

#define  for_each_process(p) \
        for (p = &init_task; (p = list_entry((p)->tasks.next, \
                                                             struct task_struct, tasks) \
                                                              ) != &init_task;)                        

转载于:https://www.cnblogs.com/miaoyong/p/4948903.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在现如今这个互联网以及信息技术飞速发展的时代,信息技术被广泛地运用于人们的日常生活与生产中,并有效地提高了办事、办公效率。教育信息化的高速发展,使得学校在线考试系统,作为一种新的考试管理工具,在各大院校及相关教育机构的运用日趋普遍。绝大多数的考试机构需要不断地推进自身信息化的建设,而在考务管理方面,以往手工记账、登记信息的方式,已经逐渐不能满足现如今大数据量、高效率完成的要求,使用学校在线考试系统,对学校及相关教育机构的考试事宜管理已成当下教育信息化发展的必要手段。现代化的考试机构都应该进行学校在线考试系统的替换工作,学校在线考试系统一经推出,便在考试机构范围内引起了极大地反响。 本次学校在线考试系统的实现过程,它的开发使用B/S结构即浏览器和服务器结构框架,采用SSM框架技术,数据库使用了mysql数据库,页面设计采用了MVC框架,后端采用了SSM框架技术scrip等其他一些脚本语言,使用到在大学里面学的软件工程导论课程、mysql数据库、数据库原理、SSM框架技术高级程序设计等方面的知识完成本系统。本文结合全流程网站系统开发过程,详细介绍了此次学校在线考试系统的设计理念、模型结构,将所学知识融入到本网站的开发实践中,简略介绍了研究的背景和系统存在的现实意义,开发使用的技术背景,并对系统概要设计、系统实现与系统测试等进行了详细的介绍。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值