uC/OS-II源码解析(ucos_ii.c)

转自:https://blog.csdn.net/u010650845/article/details/69571892

/*
** ver: 2.52
** file: uCOS_II.C
** brief: C文件集合
*/

#define  OS_GLOBALS                             /* 声明全局变量 防止重复定义             */
#include "includes.h"                           /* 包含"includes.h"头文件                */


#define  OS_MASTER_FILE        /* 防止以下文件重复定义宏OS_GLOBALS和重复包含"includes.h" */
#include "\software\ucos-ii\source\os_core.c"   /* 包含 "os_core.c" 文件                 */
#include "\software\ucos-ii\source\os_flag.c"   /* 包含 "os_flag.c" 文件                 */
#include "\software\ucos-ii\source\os_mbox.c"   /* 包含 "os_mbox.c" 文件                 */
#include "\software\ucos-ii\source\os_mem.c"    /* 包含 "os_mem.c" 文件                  */
#include "\software\ucos-ii\source\os_mutex.c"  /* 包含 "os_mutex.c" 文件                */
#include "\software\ucos-ii\source\os_q.c"      /* 包含 "os_q.c" 文件                    */
#include "\software\ucos-ii\source\os_sem.c"    /* 包含 "os_sem.c" 文件                  */
#include "\software\ucos-ii\source\os_task.c"   /* 包含 "os_task.c" 文件                 */
#include "\software\ucos-ii\source\os_time.c"   /* 包含 "os_time.c" 文件                 */

1. OS_GLOBALS栗子

ucos_ii.h文件有如下定义:

. . .
#ifdef   OS_GLOBALS               
#define  OS_EXT
#else
#define  OS_EXT  extern
#endif
. . .
OS_EXT  INT32U            OSCtxSwCtr;
. . .

includes.h文件中有如下定义:

#include    "ucos_ii.h" 

os_core.c文件有如下定义:

. . .
#define  OS_GLOBALS  
#include "includes.h"     
. . . 


因为os_core.c中定义了OS_GLOBALS这个宏,所以OS_EXT宏为空,即os_core.c文件编译结果如下

INT32U            OSCtxSwCtr;

结果是在文件os_core.c中定义变量OSCtxSwCtr,其他.c文件不会定义宏OS_GLOBALS,所以OS_EXT的值为extern,即其他.c文件编译时结果如下:

extern  INT32U            OSCtxSwCtr;

结果是在其他.c中声明变量,因为变量已经定义过了呀呀呀!

2. uCOS_II.C文件

说明:如果你的工程中添加了uCOS_II.C文件,则不要添加该文件下包含的那些C文件否则会出现重复定义错误,如果添加了各C文件则不要添加uCOS_II.C文件,这个故事告诉我们老婆与小三不能兼得【羞涩】
 

\SOFTWARE The main directory from the root where all software-related files are placed. \SOFTWARE\BLOCKS The main directory where all ‘Building Blocks’ are located. With μC/OS-II, I included a ‘building block’ that handles DOS-type compatible functions that are used by the example code. \SOFTWARE\BLOCKS\TO This directory contains the files for the TO utility (see Appendix E, TO). The source file is TO.C and is found in the \SOFTWARE\TO\SOURCE directory. The DOS executable file (TO.EXE) is found in the \SOFTWARE\TO\EXE directory. Note that TO requires a file called TO.TBL which must reside on your root directory. An example of TO.TBL is also found in the \SOFTWARE\TO\EXE directory. You will need to move TO.TBL to the root directory if you are to use TO.EXE. \SOFTWARE\uCOS-II The main directory where all μC/OS-II files are located. \SOFTWARE\uCOS-II\EX1_x86L This directory contains the source code for EXAMPLE #1 (see section 1.07, Example #1) which is intended to run under DOS (or a DOS window under Windows 95). \SOFTWARE\uCOS-II\EX2_x86L This directory contains the source code for EXAMPLE #2 (see section 1.08, Example #2) which is intended to run under DOS (or a DOS window under Windows 95). \SOFTWARE\uCOS-II\EX3_x86L This directory contains the source code for EXAMPLE #3 (see section 1.09, Example #3) which is intended to run under DOS (or a DOS window under Windows 95). \SOFTWARE\uCOS-II\Ix86L This directory contains the source code for the processor dependent code (a.k.a. the port) of μC/OS-II for an 80x86 Real-Mode, Large Model processor. \SOFTWARE\uCOS-II\SOURCE This directory contains the source code for processor independent portion of μC/OS-II. This code is fully portable to other processor architectures.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值