FreeRTOS源码解析 -> vTaskResume()
2014-12-31 18:02
363 查看
#if ( INCLUDE_vTaskSuspend == 1 ) void vTaskResume( xTaskHandle pxTaskToResume ) { tskTCB *pxTCB; /* It does not make sense to resume the calling task. */ configASSERT( pxTaskToResume ); /* Remove the task from whichever list it is currently in, and place it in the ready list. */ pxTCB = ( tskTCB * ) pxTaskToResume; /* The parameter cannot be NULL as it is impossible to resume the currently executing task. */ //要恢复的task不为空并且不是当前正在运行的task(如果是当前运行的还恢复个毛线) //熟悉的链表操作啊 if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) ) { //进入临界区 taskENTER_CRITICAL(); { //判断要恢复的task是否在挂起列表中 if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE ) { traceTASK_RESUME( pxTCB ); /* As we are in a critical section we can access the ready lists even if the scheduler is suspended. */ //从挂起链表中删除,加入到ready队列中(恢复到就绪态) vListRemove( &( pxTCB->xGenericListItem ) ); prvAddTaskToReadyQueue( pxTCB ); //如果恢复的task优先级比当前正在运行的任务的优先级高,强制一次任务调度 //这里为什么不去判断当前调度器是否在运行(之前可是都判断了的)???? /* We may have just resumed a higher priority task. */ if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { /* This yield may not cause the task just resumed to run, but will leave the lists in the correct state for the next yield. */ /*强制进行一次上下文切换*/ portYIELD_WITHIN_API(); } } } //退出临界区 taskEXIT_CRITICAL(); } } #endif
相关文章推荐
- FreeRTOS源码解析 -> vTaskDelete()
- FreeRTOS源码解析 -> vTaskDelayUntil()
- FreeRTOS源码解析 -> xTaskCreate()
- FreeRTOS源码解析 -> vTaskStartScheduler()
- FreeRTOS源码解析 -> vTaskSuspend
- volley源码解析(七)--最终目的之Response<T>
- Java源码解析 Collection<E>
- Volley源码解析<三> Request请求
- Volley 源码解析<转>
- AndroidICS4.0---->LockScreen锁屏流程【Android源码解析九】
- AFNetworking2.0源码解析<一>
- AFNetworking2.0源码解析<二>
- <自己动手写操作系统>第三章——pmtest3源码解析:使用LDT
- AFNetworking2.0源码解析<二>
- AFNetworking2.0源码解析<二>
- volley源码解析(二)--Request<T>类的介绍
- AndroidICS4.0---->LockScreen锁屏流程【Android源码解析九】
- 安装源码包 httpd-2.2.22.tar.bz2 php-5.4.10.tar.bz2 使网站可以解析以下内容 <?php phpinfo(); ?>
- AFNetworking2.0源码解析<二>
- AFNetworking2.0源码解析<一>