FreeRTOS源码解析 -> vTaskSuspend
来源:互联网 发布:日常流水账软件 编辑:程序博客网 时间:2024/06/05 06:34
“挂起(suspended)”是非运行状态的子状态。处于挂起状态的任务对调度器而言是不可见的。让一个任务进入挂起状态的唯一办法就是调用vTaskSuspend() API函数;而把一个挂起状态的任务唤醒的唯一途径就是调用vTaskResume()或vTaskResumeFromISR() API函数。大多数应用程序中都不会用到挂起状态。
#if ( INCLUDE_vTaskSuspend == 1 )void vTaskSuspend( xTaskHandle pxTaskToSuspend ){tskTCB *pxTCB; //用汇编关闭所有中断(保证我在对任务操作的时候不会因为中断而打断)taskENTER_CRITICAL();{/* Ensure a yield is performed if the current task is beingsuspended. */if( pxTaskToSuspend == pxCurrentTCB ){pxTaskToSuspend = NULL;}/* If null is passed in here then we are suspending ourselves. */pxTCB = prvGetTCBFromHandle( pxTaskToSuspend );//和删除类似的方法,都是通过上面两步找到实际要操作的tasktraceTASK_SUSPEND( pxTCB );/* Remove task from the ready/delayed list and place in thesuspended list. */vListRemove( &( pxTCB->xGenericListItem ) );/* Is the task waiting on an event also? *//* 看一下要挂起的task是否在阻塞态列表中有恢复到ready的event */if( pxTCB->xEventListItem.pvContainer ){//有的话删除,不让他通过event进入ready状态vListRemove( &( pxTCB->xEventListItem ) );} //当前任务插入挂起列表最后vListInsertEnd( ( xList * ) &xSuspendedTaskList, &( pxTCB->xGenericListItem ) );}//开中断taskEXIT_CRITICAL(); //如果挂起的是当前正在运行的任务if( ( void * ) pxTaskToSuspend == NULL ){/* 并且调度器是运行的,那么马上进行一次调度 */if( xSchedulerRunning != pdFALSE ){/* We have just suspended the current task. *//*强制上下文切换*/portYIELD_WITHIN_API();}//调度器没有在运行else{/* The scheduler is not running, but the task that was pointedto by pxCurrentTCB has just been suspended and pxCurrentTCBmust be adjusted to point to a different task. *///当前只有一个task,并且这个任务此时被挂起了if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1U ){/* No other tasks are defined, so set pxCurrentTCB back toNULL so when the next task is created pxCurrentTCB willbe set to point to it no matter what its relative priorityis. */pxCurrentTCB = NULL;}else{vTaskSwitchContext();}}}}#endif
0 0
- FreeRTOS源码解析 -> vTaskSuspend
- FreeRTOS 源码注释(vTaskSuspend)
- FreeRTOS源码解析 -> xTaskCreate()
- FreeRTOS源码解析 -> vTaskDelete()
- FreeRTOS源码解析 -> vTaskDelayUntil()
- FreeRTOS源码解析 -> vTaskStartScheduler()
- FreeRTOS源码解析 -> vTaskResume()
- FreeRTOS之源码及移植解析
- FreeRTOS的队列发送源码解析
- Tracealyzer for FreeRTOS(FreeRTOS+Trace) 详解(源码解析+移植)
- Tracealyzer for FreeRTOS(FreeRTOS+Trace) 详解(源码解析+移植)
- FreeRTOS 源码分析
- FreeRtos heap1源码分析
- FreeRtos heap2源码分析
- FreeRtos heap3源码分析
- FreeRtos heap4源码分析
- FreeRtos heap5源码分析
- FreeRTOS 源码结构说明
- JAVA 多线程
- /caching/TagDependencyTest.php 使用tag cache
- 电子商务网站互联网安全防御攻略
- TCP长连接与短连接的区别
- 基于稀疏矩阵的k近邻(KNN)实现
- FreeRTOS源码解析 -> vTaskSuspend
- Android学习 Context
- Ant
- 通信英语
- nginx上搭建HLS流媒体服务器
- 简单谈谈session机制的原理
- 将JavaFX运行到Android上
- php 操作数组 (合并,拆分,追加,查找,删除等)
- 高斯消元