FreeRTOS源码解析 -> vTaskStartScheduler()
2014-12-31 18:19
381 查看
xPortStartScheduler()会在后面介绍port.c的时候详细说明。
void vTaskStartScheduler( void ) { portBASE_TYPE xReturn; /* Add the idle task at the lowest priority. */ /*空闲任务的责任是要将分配给已删除任务的内存释放掉。 在vTaskDelete()删除任务后,在prvIdleTask释放内存*/ xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), ( xTaskHandle * ) NULL ); #if ( configUSE_TIMERS == 1 ) { if( xReturn == pdPASS ) { xReturn = xTimerCreateTimerTask(); } } #endif //上面的idle任务创建成功 if( xReturn == pdPASS ) { /* Interrupts are turned off here, to ensure a tick does not occur before or during the call to xPortStartScheduler(). The stacks of the created tasks contain a status word with interrupts switched on so interrupts will automatically get re-enabled when the first task starts to run. STEPPING THROUGH HERE USING A DEBUGGER CAN CAUSE BIG PROBLEMS IF THE DEBUGGER ALLOWS INTERRUPTS TO BE PROCESSED. */ portDISABLE_INTERRUPTS(); //调度器flag,用于判断调度器是否在运行 xSchedulerRunning = pdTRUE; //计数器清零 xTickCount = ( portTickType ) 0; /* If configGENERATE_RUN_TIME_STATS is defined then the following macro must be defined to configure the timer/counter used to generate the run time counter time base. */ portCONFIGURE_TIMER_FOR_RUN_TIME_STATS(); /* Setting up the timer tick is hardware specific and thus in the portable interface. */ /*启动任务调度*/ if( xPortStartScheduler() ) { /* Should not reach here as if the scheduler is running the function will not return. */ } else { /* Should only reach here if a task calls xTaskEndScheduler(). */ } } /* This line will only be reached if the kernel could not be started. */ configASSERT( xReturn ); }
相关文章推荐
- FreeRTOS源码解析 -> vTaskDelayUntil()
- FreeRTOS源码解析 -> vTaskResume()
- FreeRTOS源码解析 -> vTaskSuspend
- FreeRTOS源码解析 -> vTaskDelete()
- FreeRTOS源码解析 -> xTaskCreate()
- FreeRTOS 源码注释(vTaskDelayUntil)
- Android ApiDemos示例解析(44):App->Service->Service Start Arguments Controller
- AFNetworking2.0源码解析<二>
- <自己动手写操作系统>第三章pmtest7源码解析——检测系统内存
- OpenStack Nova-scheduler组件的源码解析(2)
- VLFeat库->LBP特征源码解析
- AndroidICS4.0---->LockScreen锁屏流程【Android源码解析九】
- 安装源码包 httpd-2.2.22.tar.bz2 php-5.4.10.tar.bz2 使网站可以解析以下内容 <?php phpinfo(); ?>
- nohup ./startWebLogic.sh >out.log 2>&1 & 解析
- OpenStack Nova-scheduler组件的源码解析(1)
- OpenStack Nova-scheduler组件的源码解析(2)
- FreeRTOS 源码注释(vTaskDelayUntil)
- Uboot中start.S源码的指令级的详尽解析 在线版
- Uboot中start.S源码的指令级的详尽解析
- AFNetworking2.0源码解析<二>