摘要
针对环形队列入队、出队时取余运算耗时问题,提出一种使用按位与运算的方法,大大缩短了入队、出队耗时;针对批量写入/读出数据时,使用单字节方式效率低的缺点,提出了一种对队列一次性读/写多字节的实现方式。实际测试结果表明,本文提出的方法耗时更少、执行效率更高。
Abstract
In order to solve the problem of time consuming in the process of queue entry and queue exit,this paper proposes a method of bit-sum operation,which greatly reduces the time consuming in queue entry and queue exit.In view of the low efficiency of using single byte mode when writing and reading data in batch,this paper proposes a way to read and write multiple bytes in a queue at one time.The actual test shows that the proposed method is less time-consuming and more efficient.
关键词
环形队列 /
MCU /
嵌入式系统
Key words
ring queue /
MCU /
embedded system
梁凤涛.
单片机中环形队列取余运算的改进[J]. 集成电路与嵌入式系统. 2023, 23(9): 65-66
Liang Fengtao.
Improvement of Ring Queue Remainder Calculation in MCU[J]. Integrated Circuits and Embedded Systems. 2023, 23(9): 65-66
{{custom_sec.title}}
{{custom_sec.title}}
{{custom_sec.content}}
参考文献
[1] 严蔚敏.数据结构(C语言版)[M].北京:清华大学出版社,2007.
[2] Kenneth A Reek. Pointers on C[M].徐波,译.北京:人民邮电出版社,2017.
[3] 李精华.微机原理与单片机接口技术[M].北京:电子工业出版社,2018.
[4] 张淑清.嵌入式单片机STM32原理及应用[M].北京:机械工业出版社,2019.