Linux 内核中的队列 [英] Queues in the Linux Kernel

查看:34
本文介绍了Linux 内核中的队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找有关队列的通用内核实现的信息,即先进先出数据结构.我认为可能有一个,因为它可能是常用的东西,并且有一个链接列表的标准(以 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆