当前位置: 首页 > news >正文

门户网站的特点和优势常州网签备案查询

门户网站的特点和优势,常州网签备案查询,建站系统哪个好,大润发超市网上商城layout: post title: “任务状态” date: 2023-7-19 15:39:08 0800 tags: FreeRTOS 任务状态 fireRTOS代码分析 任务挂起 //把一个任务挂起 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) {TCB_t *pxTCB;taskENTER_CRITICAL();//进入临界区{/* 参数是NULL的时候设置为当… layout: post title: “任务状态” date: 2023-7-19 15:39:08 0800 tags: FreeRTOS 任务状态 fireRTOS代码分析 任务挂起 //把一个任务挂起 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) {TCB_t *pxTCB;taskENTER_CRITICAL();//进入临界区{/* 参数是NULL的时候设置为当前任务, 否则返回这一个参数的TCB */pxTCB prvGetTCBFromHandle( xTaskToSuspend );traceTASK_SUSPEND( pxTCB );/* 从就绪列表里面移除 */if( uxListRemove( ( pxTCB-xStateListItem ) ) ( UBaseType_t ) 0 ){//重新设置优先级taskRESET_READY_PRIORITY( pxTCB-uxPriority );}else{mtCOVERAGE_TEST_MARKER();}/* 检测这一个任务是不是在等待一个事件 */if( listLIST_ITEM_CONTAINER( ( pxTCB-xEventListItem ) ) ! NULL ){//是的话把他从事件链表里面移除( void ) uxListRemove( ( pxTCB-xEventListItem ) );}//插入挂起的队列vListInsertEnd( xSuspendedTaskList, ( pxTCB-xStateListItem ) );#if( configUSE_TASK_NOTIFICATIONS 1 ){if( pxTCB-ucNotifyState taskWAITING_NOTIFICATION ){/* The task was blocked to wait for a 通知, but isnow suspended, so no notification was received. */pxTCB-ucNotifyState taskNOT_WAITING_NOTIFICATION;}}#endif}taskEXIT_CRITICAL();if( xSchedulerRunning ! pdFALSE ){/* 重新设置一下下一个软件时钟的时间(一般用于Delay以及等待事件) */taskENTER_CRITICAL();{prvResetNextTaskUnblockTime();}taskEXIT_CRITICAL();}if( pxTCB pxCurrentTCB ){if( xSchedulerRunning ! pdFALSE ){/* 调度器在运行 */configASSERT( uxSchedulerSuspended 0 );//切换任务portYIELD_WITHIN_API();}else{/* 调度器没有运行(不能进行任务切换) */if( listCURRENT_LIST_LENGTH( xSuspendedTaskList ) uxCurrentNumberOfTasks ){/* 没有其他的任务了 */pxCurrentTCB NULL;}else{//把记录当前任务的全局变量改为优先级最高的一个任务vTaskSwitchContext();}}}else{mtCOVERAGE_TEST_MARKER();} }恢复挂起的任务 //恢复挂起的任务 void vTaskResume( TaskHandle_t xTaskToResume ) {TCB_t * const pxTCB ( TCB_t * ) xTaskToResume;/* 同上 */if( ( pxTCB ! NULL ) ( pxTCB ! pxCurrentTCB ) ){taskENTER_CRITICAL();{//检测是不是真的被挂起了if( prvTaskIsTaskSuspended( pxTCB ) ! pdFALSE ){traceTASK_RESUME( pxTCB );/* 从挂起的链表里面移除 */( void ) uxListRemove( ( pxTCB-xStateListItem ) );//加入就绪列表prvAddTaskToReadyList( pxTCB );/* A higher priority task may have just been resumed. */if( pxTCB-uxPriority pxCurrentTCB-uxPriority ){/* 优先级比较当前任务高, 进行一次任务切换 */taskYIELD_IF_USING_PREEMPTION();}}}taskEXIT_CRITICAL();} }//恢复所有挂起的任务 BaseType_t xTaskResumeAll( void ) { TCB_t *pxTCB NULL; BaseType_t xAlreadyYielded pdFALSE;/* If uxSchedulerSuspended is zero then this function does not match aprevious call to vTaskSuspendAll(). */configASSERT( uxSchedulerSuspended );/* It is possible that an ISR caused a task to be removed from an eventlist while the scheduler was suspended. If this was the case then theremoved task will have been added to the xPendingReadyList. Once thescheduler has been resumed it is safe to move all the pending readytasks from this list into their appropriate ready list. 如果之前的任务有在ISR中并且任务调度实现的时候被从事件List里面移除, 需要处理 */taskENTER_CRITICAL();{//任务切换挂起的记录减一--uxSchedulerSuspended;if( uxSchedulerSuspended ( UBaseType_t ) pdFALSE ){if( uxCurrentNumberOfTasks ( UBaseType_t ) 0U ){/* Move any readied tasks from the pending list into theappropriate ready list. 这是一个等待恢复的队列, 一般是在时钟挂起的时候转为ready的任务 */while( listLIST_IS_EMPTY( xPendingReadyList ) pdFALSE ){//处理待处理的任务pxTCB ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( xPendingReadyList ) );( void ) uxListRemove( ( pxTCB-xEventListItem ) );( void ) uxListRemove( ( pxTCB-xStateListItem ) );prvAddTaskToReadyList( pxTCB );/* If the moved task has a priority higher than the currenttask then a yield must be performed. */if( pxTCB-uxPriority pxCurrentTCB-uxPriority ){//需要优先级切换xYieldPending pdTRUE;}else{mtCOVERAGE_TEST_MARKER();}}if( pxTCB ! NULL ){/* A task was unblocked while the scheduler was suspended,which may have prevented the next unblock time from beingre-calculated, in which case re-calculate it now. Mainlyimportant for low power tickless implementations, wherethis can prevent an unnecessary exit from low powerstate. 更新一下下一个需要处理的Delay时钟的值 */prvResetNextTaskUnblockTime();}/* If any ticks occurred while the scheduler was suspended thenthey should be processed now. This ensures the tick count doesnot slip, and that any delayed tasks are resumed at the correcttime. 处理挂期间任务的待处理事项*/{UBaseType_t uxPendedCounts uxPendedTicks; /* Non-volatile copy. */if( uxPendedCounts ( UBaseType_t ) 0U ){do{//调用时钟处理函数, 更新一下时钟值if( xTaskIncrementTick() ! pdFALSE ){xYieldPending pdTRUE;}else{mtCOVERAGE_TEST_MARKER();}--uxPendedCounts;//记录挂起的时钟数} while( uxPendedCounts ( UBaseType_t ) 0U );uxPendedTicks 0;}else{mtCOVERAGE_TEST_MARKER();}}if( xYieldPending ! pdFALSE ){#if( configUSE_PREEMPTION ! 0 ){xAlreadyYielded pdTRUE;}#endif//任务切换taskYIELD_IF_USING_PREEMPTION();}}}taskEXIT_CRITICAL();return xAlreadyYielded; }延时函数 void vTaskDelay( const TickType_t xTicksToDelay ) {BaseType_t xAlreadyYielded pdFALSE;/* A delay time of zero just forces a reschedule. */if( xTicksToDelay ( TickType_t ) 0U ){vTaskSuspendAll();{/* A task that is removed from the event list while thescheduler is suspended will not get placed in the readylist or removed from the blocked list until the scheduleris resumed.This task cannot be in an event list as it is the currentlyexecuting task. 把这一个任务插入Delay队列里面 */prvAddCurrentTaskToDelayedList( xTicksToDelay, pdFALSE );}xAlreadyYielded xTaskResumeAll();}/* Force a reschedule if xTaskResumeAll has not already done so, we mayhave put ourselves to sleep. */if( xAlreadyYielded pdFALSE ){portYIELD_WITHIN_API();}else{mtCOVERAGE_TEST_MARKER();} }static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely ) { TickType_t xTimeToWake; const TickType_t xConstTickCount xTickCount;/* 把当前的任务从运行的任务里面删除 */if( uxListRemove( ( pxCurrentTCB-xStateListItem ) ) ( UBaseType_t ) 0 ){/* 这个优先级没有任务了, 清除标志位 */portRESET_READY_PRIORITY( pxCurrentTCB-uxPriority, uxTopReadyPriority );}else{mtCOVERAGE_TEST_MARKER();}if( ( xTicksToWait portMAX_DELAY ) ( xCanBlockIndefinitely ! pdFALSE ) ){/* 设置的时间是无限, 直接挂起. */vListInsertEnd( xSuspendedTaskList, ( pxCurrentTCB-xStateListItem ) );}else{/* 计算唤醒的时间 */xTimeToWake xConstTickCount xTicksToWait;/* 设置时钟 */listSET_LIST_ITEM_VALUE( ( pxCurrentTCB-xStateListItem ), xTimeToWake );if( xTimeToWake xConstTickCount ){/* 溢出列表. */vListInsert( pxOverflowDelayedTaskList, ( pxCurrentTCB-xStateListItem ) );}else{/* 不是溢出 */vListInsert( pxDelayedTaskList, ( pxCurrentTCB-xStateListItem ) );/* 设置下一次的唤醒时间 */if( xTimeToWake xNextTaskUnblockTime ){xNextTaskUnblockTime xTimeToWake;}else{mtCOVERAGE_TEST_MARKER();}}}}void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) {TickType_t xTimeToWake;BaseType_t xAlreadyYielded, xShouldDelay pdFALSE;configASSERT( pxPreviousWakeTime );configASSERT( ( xTimeIncrement 0U ) );configASSERT( uxSchedulerSuspended 0 );vTaskSuspendAll();{/* Minor optimisation. The tick count cannot change in thisblock. */const TickType_t xConstTickCount xTickCount;/* Generate the tick time at which the task wants to wake. */xTimeToWake *pxPreviousWakeTime xTimeIncrement;//节拍器溢出if( xConstTickCount *pxPreviousWakeTime ){/* 唤醒时间和现在的时间都已经溢出过了 */if( ( xTimeToWake *pxPreviousWakeTime ) ( xTimeToWake xConstTickCount ) ){xShouldDelay pdTRUE;}else{mtCOVERAGE_TEST_MARKER();}}else{/* 只有溢出时间溢出了, 或者都没有溢出 */if( ( xTimeToWake *pxPreviousWakeTime ) || ( xTimeToWake xConstTickCount ) ){xShouldDelay pdTRUE;}else{mtCOVERAGE_TEST_MARKER();}}/* Update the wake time ready for the next call. */*pxPreviousWakeTime xTimeToWake;if( xShouldDelay ! pdFALSE ){traceTASK_DELAY_UNTIL( xTimeToWake );/* 插入到延时链表里面 */prvAddCurrentTaskToDelayedList( xTimeToWake - xConstTickCount, pdFALSE );}else{mtCOVERAGE_TEST_MARKER();}}xAlreadyYielded xTaskResumeAll();/* Force a reschedule if xTaskResumeAll has not already done so, we mayhave put ourselves to sleep. */if( xAlreadyYielded pdFALSE ){portYIELD_WITHIN_API();}else{mtCOVERAGE_TEST_MARKER();} }
http://www.hkea.cn/news/14453789/

相关文章:

  • 凡科网建站入门教程网站建设推广怎么做
  • 陕西营销型手机网站建设广州建站免费模板
  • wordpress 全站pjax湖南住房和城乡建设厅网站首页
  • 池州做网站的公司wordpress柒主题
  • 网站建设列入什么会计科目广州专业做网站排名哪家好
  • 潜江市建设工程合同备案网站自己做的网站怎么置顶
  • 潍坊百度seoseo营销
  • 网站群建设工作培训会网站源码大全免费的
  • wordpress网站导入越秀网站建设推广
  • 青海网站建设公司多少钱临沂高端网站建设
  • 网站手机页面做多大wordpress加密数据库文件夹
  • 做网站有没有用网站建设 付款方式
  • 旅游网站建设的规模设想网站开发课程学习报告
  • 网站设计公司网站专业建设资格执业注册中心网站
  • 网站的系统帮助东莞企业网站咨询
  • 湖南土特产销售网网站建设制作建设网站怎么赚钱的
  • 网站建设用dw怎么创建网页链接
  • 上市公司网站建设评价北京好网站制作公司
  • 徐州企业制作网站企业网站模板论坛
  • 如果做网站推广网站模板设计举例
  • 做本地网站要服务器吗海外电商能赚钱吗
  • 加盟型网站建设北京微网站建设公司
  • 网站建设与管理卷子网站建设与管理模拟试卷
  • 免费crm网站不用下载的软件个人主页原型图
  • 福田专业做网站公司wordpress 首页修改
  • 保山网站建设报价洛阳市有哪些平台公司
  • 做网站需要服务器和什么软件网站都必须要备案吗
  • 好的空间网站什么网站做烘干设备好
  • 青岛市建设网站wordpress伪静态不收录
  • 网页设计模板免费下载网站高端品牌网站建设的特点