摘要
介绍了MCS-51单片机的内存分布、C51变量存储方式和函数参数传递方式,由此引发了对C51函数可重入性问题的思考和分析。与其他处理器C语言编译器不同的是,除了在函数体中显式访问全局资源会破坏函数的可重入性之外,C51函数参数传递和局部变量存储分配空间时,可能存在隐式的全局资源访问冲突,同样会导致函数不可重入。通过对各种情况下的全局资源访问冲突分析,提出了相应的解决方案以避免不可重入函数被多任务调用引起软件运行异常。
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.
作者
朱剑辉
刘胜阳
郑渊
洪小骏
苏思友
Zhu Jianhui;Liu Shengyang;Zheng Yuan;Hong Xiaojun;Su Siyou(Shanghai Aerospace Electronic Technology Institute,Shanghai 201108,China;Shanghai Academy of Spaceflight Technology)
出处
《单片机与嵌入式系统应用》
2023年第8期4-7,共4页
Microcontrollers & Embedded Systems