作者投稿和查稿 主编审稿 专家审稿 编委审稿 远程编辑

计算机工程 ›› 2012, Vol. 38 ›› Issue (08): 228-231.

• 工程应用技术与实现 • 上一篇    下一篇

一种高性能环形缓冲区的研究与实现

姚章俊 a,陈蜀宇 b,卢 尧 a   

  1. (重庆大学 a. 计算机学院;b. 软件学院,重庆 400030)
  • 收稿日期:2011-07-20 出版日期:2012-04-20 发布日期:2012-04-20
  • 作者简介:姚章俊(1987-),男,硕士研究生,主研方向:网络体系结构;陈蜀宇,教授、博士生导师;卢 尧,硕士研究生
  • 基金资助:
    科技部国际科技合作基金资助项目(2007DFR10420);重庆市自然科学基金资助项目(2008BB2307)

Research and Implementation of High-performance Ring Buffer

YAO Zhang-jun a, CHEN Shu-yu b, LU Yao a   

  1. (a. College of Computer Science; b. College of Software Engineering, Chongqing University, Chongqing 400030, China)
  • Received:2011-07-20 Online:2012-04-20 Published:2012-04-20

摘要: 基于单生产者多消费者模型,剖析传统环形缓冲区写入和读出进程并发操作的缺陷,提出一种带有缓冲区单元状态标记的算法,解决环形缓冲区写入和读出进程的同步问题。定量分析产生环形缓冲区性能瓶颈的条件,在不满足该条件的情况下,环形缓冲区的性能会有大幅提升。对比实验和数学分析验证了该环形缓冲区处理数据包的性能较好。

关键词: 环形缓冲区, 进程同步, 生产者, 消费者, 单元状态

Abstract: Based on the model of single producer multiple consumers, the drawback of the writing concurrency and reading processes in traditional ring buffer is analysed. An algorithm with tagged buffer unit status is presented to solve the synchronization problem of writing and reading processes in the ring buffer. And the condition resulted in the bottleneck of the ring buffer performance is analysed quantificationally. The performance of the ring buffer is promoted greatly if the condition does not be met. Contrastive experiment and mathematical analysis verify that the performance of data packet processing in the ring buffer is better.

Key words: ring buffer, process synchronization, producer, consumer, unit status

中图分类号: