Linux内核中的队列 [英] Queues in the Linux Kernel
问题描述
我一直在寻找一个通用内核实现队列的信息,也就是先进先出的数据结构。我认为可能有一个,因为它可能是常用的东西,并且有一个链表(以list_head结构的形式)的标准。有没有一些标准的队列实现,我找不到,或者通常的做法是使用链接列表作为队列,希望最好?
I've been searching for information for a common kernel implementation of queues, that is, first-in-first-out data structures. I thought there may be one since it's likely something that's common to use, and there's a standard for linked lists (in the form of the list_head structure). Is there some standard queue implementation I can't find, or is it perhaps common practice to just use linked lists as queues and hope for the best?
推荐答案
你说得对,Linux内核通常使用链表实现队列。这是有道理的,因为链接列表提供了所需的行为。请参阅kernel / workqueue.c中的这个例子:
You're right, the Linux kernel typically uses linked lists to implement queues. This makes sense, because linked lists offer the required behavior. See this example from kernel/workqueue.c:
INIT_LIST_HEAD(&wq->list);
// ...
case CPU_UP_CANCELED:
list_for_each_entry(wq, &workqueues, list) {
if (!per_cpu_ptr(wq->cpu_wq, hotcpu)->thread)
这篇关于Linux内核中的队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!