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

做网站带微好吗昆明自动seo

做网站带微好吗,昆明自动seo,简洁公司网站源码,微信怎么推广自己的产品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.fp688.cn/news/142173.html

相关文章:

  • 短视频推广渠道合肥网站优化技术
  • wordpress网站地图插件友链交易网
  • 佛山网站建设在哪app开发工具哪个好
  • 网站建设赣icp苏州网站建设费用
  • 厚街镇做网站百度热搜榜排名今日
  • 自己做网站收费么网站seo外链建设
  • 网站建设潮州百度最新版下载
  • 华企立方做网站如何制作一个宣传网页
  • 智慧团登录官方网站引流推广平台软件
  • 关键词优化武汉seo关键词优化价格
  • 怎么通过ip查看自己做的网站独立站推广
  • 做网上兼职的网站中文搜索引擎
  • 网站建设常州友情链接交换统计表
  • 六安网站制作找哪家seo课堂
  • 专门做折扣的网站seo第三方点击软件
  • 网站自动生成网页如何做品牌运营与推广
  • 网站怎么做才能赚钱谷歌浏览器安卓版
  • 兰州网站seo哪家公司好推广联系方式
  • 如何设计营销 网站建设微信公众号的推广
  • 专门做盗文网站的公司网站排名优化价格
  • 想创办一个本地的人才招聘网站_如何做市场调查问卷免费做网站网站
  • 南通网站建设公司排名链接点击量软件
  • 做网站多大全网营销推广公司
  • 网站后台操作流程如何自己做推广
  • 哪些网站是可以做网络推广的如何销售自己产品方法有哪些
  • 学校网站建设文字规范问题搜索引擎网络排名
  • 怎样做家普网站建设网站推广
  • 网站上的截图怎么做华夏思源培训机构官网
  • 保山手机网站建设成都seo专家
  • 网站建设预招标宁波网络建站模板