深入剖析51单片机软件函数的可重入性问题

朱剑辉, 刘胜阳, 郑渊, 洪小骏, 苏思友

集成电路与嵌入式系统 ›› 2023, Vol. 23 ›› Issue (8) : 4-7.

PDF(947 KB)
PDF(947 KB)
集成电路与嵌入式系统 ›› 2023, Vol. 23 ›› Issue (8) : 4-7.
专题论述

深入剖析51单片机软件函数的可重入性问题

  • 朱剑辉1, 刘胜阳1, 郑渊2, 洪小骏1, 苏思友1
作者信息 +

In-depth Analysis of 51 Microcontroller Software Function Reentrant Problem

  • Zhu Jianhui1, Liu Shengyang1, Zheng Yuan2, Hong Xiaojun1, Su Siyou1
Author information +
文章历史 +

摘要

介绍了MCS-51单片机的内存分布、C51变量存储方式和函数参数传递方式,由此引发了对C51函数可重入性问题的思考和分析。与其他处理器C语言编译器不同的是,除了在函数体中显式访问全局资源会破坏函数的可重入性之外,C51函数参数传递和局部变量存储分配空间时,可能存在隐式的全局资源访问冲突,同样会导致函数不可重入。通过对各种情况下的全局资源访问冲突分析,提出了相应的解决方案以避免不可重入函数被多任务调用引起软件运行异常。

Abstract

In the paper,the memory distribution of MCS-51 microcontroller,the storage mode of C51 variable and the transfer mode of function parameter are introduced,which causes the thinking and analysis of the reentrant problem of C51 function.Unlike other processor C compilers,in addition to the fact that explicit access to global resources in the body of a function breaks function reentrant,C51 function parameter passing and local variable store allocation may also result in implicit global resource access conflicts that cause function non-reentrant.Based on the analysis of global resource access conflicts in various cases,the corresponding solutions are put forward to avoid software running exceptions caused by non-reentrant function being called by multi-task.

关键词

MCS-51 / 内存分布 / 变量存储 / 参数传递 / 访问冲突

Key words

MCS-51 / memory distribution / storage mode / parameter passing / access conflict

引用本文

导出引用
朱剑辉, 刘胜阳, 郑渊, 洪小骏, 苏思友. 深入剖析51单片机软件函数的可重入性问题[J]. 集成电路与嵌入式系统. 2023, 23(8): 4-7
Zhu Jianhui, Liu Shengyang, Zheng Yuan, Hong Xiaojun, Su Siyou. In-depth Analysis of 51 Microcontroller Software Function Reentrant Problem[J]. Integrated Circuits and Embedded Systems. 2023, 23(8): 4-7
中图分类号: TP31   

参考文献

[1] 张毅刚,刘杰.MCS-51单片机原理及应用[M].哈尔滨:哈尔滨工业大学出版社,2008.
[2] 赵利民.C51堆栈构成与空间需求分析[J].自动化与仪器仪表,2012(2):154-158.
[3] 张玉峰,荀建军.Keil C51中C51程序与汇编程序的接口方法[J].软件技术,2006,24(58):58-60.
[4] 徐爱钧,彭秀华.单片机高级语言C51与汇编语言ASM51的通用接口[J].微计算机应用,2000,21(1):31-35.
[5] 雷电.96系列单片机C语言函数的重入与非重入性[J].应用与实践,1996,12(1):45-47.
[6] 阮海蓉.Keil C51中变量的使用[J].单片机与嵌入式系统应用,2011,11(1):67-69.
[7] 吴光文,周航慈.51单片机操作系统开发中的问题与技巧[J].单片机与嵌入式系统应用,2004(11):75-76.
[8] 朱博,许伦辉.Keil C51中函数指针的使用[J].单片机与嵌入式系统应用,2008(5):71-72.

PDF(947 KB)

Accesses

Citation

Detail

段落导航
相关文章

/