gpt4 book ai didi

linux-kernel - 为什么Linux内核使用循环双向链表来存储进程列表?

转载 作者:行者123 更新时间:2023-12-04 02:44:04 25 4
gpt4 key购买 nike

Linux 内核将进程列表存储在一个循环双向链表中,称为任务列表。背后的原因是什么?为什么使用循环双向链表?使用这种数据结构有什么好处?创建者试图通过使用这种数据结构来实现什么?

最佳答案

灵活性,因此如果您知道例如您要搜索的内容可能已经落后,您可以使用 list_for_each_entry_reverse宏而不是通常的前向宏。

"you use linked lists when iterating over the whole list is important and the dynamic addition and removal of elements is required ... Using this type of linked list provides the greatest flexibility"



并且没有重复的代码

"In the old days, there were multiple implementations of linked lists in the kernel. A single, powerful linked list implementation was needed to remove duplicate code. During the 2.1 kernel development series, the official kernel linked-list implementation was introduced."



资料来源:罗伯特·洛夫。 “Linux 内核开发”(第 3 版)。第 87-94 页

关于linux-kernel - 为什么Linux内核使用循环双向链表来存储进程列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46089965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com