μC/OS-II启动过程

拿之前μC/OS-II的测试代码为例,μC/OS-II启动过程主要分成三个部分:

  1. 系统初始化:包括各种硬件外设功能的初始化,系统参数初始化
  2. 任务创建:创建用户任务
  3. 运行系统:找到最高优先级的用户任务,标志相应任务控制块,然后执行。
int main()
{
 
  OSInit();     
  OSTaskCreate((void (*) (void *))LE0_task, (void *) 0,(OS_STK *)&LD0stk[63],  3);
  OSTaskCreate((void (*) (void *))LE1_task, (void *) 0,(OS_STK *)&LD1stk[63],  4);
  OS_CPU_SysTickInit();
  OSStart(); 
	while(1)
	{
 		
	}
}

系统初始化

系统初始化包括各种硬件外设功能的初始化,系统参数初始化,这里只对系统参数初始化进行说明,系统参数初始化调用OSInit完成。

void  OSInit (void)
{
    OSInitHookBegin();             //调用用户特定的初始化代码

    OS_InitMisc();                //基础参数初始化              

    OS_InitRdyList();             //任务就绪表初始化

    OS_InitTCBList();             //任务控制块初始化     

    OS_InitEventList();           //时间控制块初始化   

#if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
    OS_FlagInit();                                               //事件标志组初始化
#endif

#if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
    OS_MemInit();                                                //内存管理初始化
#endif

#if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
    OS_QInit();                                                  //消息队列初始化
#endif

    OS_InitTaskIdle();                                           //创建空闲任务
#if OS_TASK_STAT_EN > 0
    OS_InitTaskStat();                                           //创建状态任务
#endif

#if OS_TMR_EN > 0
    OSTmr_Init();                                               //定时器管理初始化
#endif

    OSInitHookEnd();                                           //调用用户特定的初始化

#if OS_DEBUG_EN > 0
    OSDebugInit();                                              //调试初始化
#endif
}

运行系统


void  OSStart (void)
{
    if (OSRunning == OS_FALSE) {
        OS_SchedNew();                               /* Find highest priority's task priority number   */
        OSPrioCur     = OSPrioHighRdy;
        OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
        OSTCBCur      = OSTCBHighRdy;
        OSStartHighRdy();                            /* Execute target specific code to start task     */
    }
}

 

This book describes the design and implementation of mC/OS-II (pronounced "Micro C O S 2") which stands for<br>Micro-Controller Operating System Version 2. μC/OS -II is based on μC/OS, The Real-Time Kernel which was first<br>published in 1992. Thousands of people around the world are using μC/OS in all kinds of applications such as<br>cameras, medical instruments, musical instruments, engine controls, network adapters, highway telephone call boxes,<br>ATM machines, industrial robots, and many more. Nu merous colleges and Universities have also used μC/OS to<br>teach students about real-time systems.<br>μC/OS-II is upward compatible with μC/OS (V1.11) but provides many improvements over μC/OS such as the<br>addition of a fixed-sized memory manager, user definable callouts on task creation, task deletion, task switch and<br>system tick, supports TCB extensions, stack checking and, much more. I also added comments to just about every<br>function and I made μC/OS -II much easier to port to different processors. The source code in μC/OS was found in two<br>source files. Because μC/OS-II contains many new features and functions, I decided to split μC/OS-II in a few source<br>files to make the code easier to maintain.<br>If you currently have an application (i.e. product) that runs with μC/OS, your application should be able to run,<br>virtually unchanged, with μC/OS-II. All of the services (i.e. function calls) provided by μC/OS have been preserved.<br>You may, however, have to change include files and product build files to ‘point’ to the new file names.<br>This book contains ALL the source code for μC/OS-II and a port for the Intel 80x86 processor running in Real-Mode<br>and for the Large Model. The code was developed on a PC running the Microsoft Windows 95 operating system.<br>Examples run in a DOS compatible box under the Windows 95 environment. Development was done using the<br>Borland International C/C++ compiler version 3.1. Although μC/OS-II was developed and tested on a PC, mC/OS-II<br>was actually targeted for embedded systems and can easily be ported to many different processor architectures.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值