内核数据结构 —— 内核队列 (kfifo)(转)

原文链接:https://blog.csdn.net/zhoutaopower/article/details/86491852参考链接:https://blog.csdn.net/fuyajun01/article/details/7413579?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=di...
摘要由CSDN通过智能技术生成

原文链接:https://blog.csdn.net/zhoutaopower/article/details/86491852

参考链接:https://blog.csdn.net/fuyajun01/article/details/7413579?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

                https://blog.csdn.net/yusiguyuan/article/details/41985907?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

                https://www.cnblogs.com/sky-heaven/p/8257288.html

                https://blog.csdn.net/linyt/article/details/53355355?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

                 https://blog.csdn.net/idwtwt/article/details/79442046?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

                https://blog.csdn.net/weixin_30301183/article/details/97072654?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

内核队列介绍
FIFO 先入先出队列是最常用的数据结构之一,在生产者——消费者模型中扮演了很重要的角色。

Linux 内核实现了一种称之为 kfifo 的内核队列,用于满足对数据有先入先出的场景。

对于通用的 fifo 而言,需要提供最基本的几个接口:

队列的分配
队列的初始化
队列的释放
队列的数据入列
队列的数据出列
队列判满
队列判空
有了上述几组接口,我们才能够算是真正能够操作并使用一个队列。

内核队列的设计精妙之处在于:

保证缓冲区大小为2的次幂,不是的向上取整为2的次幂。
使用无符号整数保存输入(in)和输出(ou

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值