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

学校网站建设的优势和不足百度搜索引擎收录入口

学校网站建设的优势和不足,百度搜索引擎收录入口,班级网站主页设计模板,欧模网室内设计效果图FreeRTOS任务基础知识 1. 什么是多任务系统?2. FreeRTOS任务3. 任务状态3.1 运行态3.2 就绪态3.3 阻塞态3.4 挂起态 4. 任务优先级5. 任务的实现6. 任务控制块7. 任务堆栈 FreeRTOS的核心是任务管理,以下介绍FreeRTOS任务的一些基础知识。 1. 什么是多任…

FreeRTOS任务基础知识

  • 1. 什么是多任务系统?
  • 2. FreeRTOS任务
  • 3. 任务状态
    • 3.1 运行态
    • 3.2 就绪态
    • 3.3 阻塞态
    • 3.4 挂起态
  • 4. 任务优先级
  • 5. 任务的实现
  • 6. 任务控制块
  • 7. 任务堆栈

FreeRTOS的核心是任务管理,以下介绍FreeRTOS任务的一些基础知识。

1. 什么是多任务系统?

  • FreeRTOS是一个抢占式多任务系统,它的任务调度器也是抢占式的。
  • 基本原理:
    1. 高优先级的任务可以打断低优先级的任务,取得CPU的使用权,从而保证紧急任务的运行。
    2. 高优先级的任务执行完成后,重新释放CPU的使用权,低优先级的任务才可以继续执行。
      在这里插入图片描述

2. FreeRTOS任务

  • 每个实时应用都可以作为一个独立的任务。
  • 任何一个时间点只能有一个任务运行,具体运行哪一个任务是由任务调度器来决定的,因此任务调度器会不断地的开启、关闭每个任务。
  • 任务调度器的职责是确保每个任务开始执行时其上下文环境(寄存器值、堆栈内容等)和任务上一次退出的时候相同。为了做到这一点,每个任务都必须有个堆栈,当任务切换时将上下文环境保存到堆栈中,这样任务再次执行时就可以从堆栈中取出上下文环境,任务恢复执行。

3. 任务状态

3.1 运行态

  • 一个任务运行时,就处于就绪态,处于运行态的任务就是当前正在执行的任务。

3.2 就绪态

  • 处于就绪态的任务就是那些已经准备就绪的任务(未被挂起或者阻塞),但是还没有运行是因为有一个同优先级或者更高优先级的任务正在运行。

3.3 阻塞态

  • 如果一个任务正在等候某一个外部事件,则该任务处于阻塞态。任务进入阻塞态会有一个超时时间,超过这个超时时间任务会退出阻塞态,即使所等待的事件还没有来临。

3.4 挂起态

  • 任务进入挂起态后不能被任务调度器调用进入运行态,但是进入挂起态的任务没有超时时间。
  • 任务进入和退出挂起态只有通过调用函数 vTaskSuspend() 和 vTaskResume() 来实现。
    在这里插入图片描述

4. 任务优先级

  • 每个任务都可以分配一个从0 ~ (configMAX_PRIORITIES - 1) 的优先级。
  • 优先级的数字越低表示任务的优先级越低,0是最低优先级。
  • 空闲任务的优先级最低,为0。
  • FreeROTS调度器确保处于就绪态或者运行态的高优先级的任务获取处理器使用权。处于就绪态的高优先级任务才会运行。
  • 当宏 configUSE_TIME_SLICING 定义为1,多个任务可以共用一个优先级,数量不限。系统默认设置为1,处于就绪态的优先级相同的多个任务会使用时间片轮转调度器获取运行时间。

5. 任务的实现

  • 使用FreeRTOS过程中,创建任务会使用函数 xTaskCreate() 或 xTaskCreateStatic() 。
  • 两个函数的第一个参数都是 pxTaskCode,表示任务的任务函数,任务函数就是完成本任务工作的函数。
/* 任务函数示例 */
/* 函数返回值类型一定要为void类型,任务的参数也是void指针类型。 */
void vTaskCode( void * pvParameters )
{for( ;; ){/* Task code goes here. */vTaskDelay(); /* 此处只要是能让FreeRTOS发生任务切换的函数即可。 */}/* 正常任务不允许退出循环,如果要跳出,则需要删除任务 */vTaskDelete(NULL);
}

6. 任务控制块

  • FreeRTOS每个任务都有一个属性需要存储,把这些属性集合到一起用一个结构体来表示,这个结构体就是任务控制块:TCB_t。
  • 使用任务创建函数时,会自动给每个任务分配一个任务控制块。
typedef struct tskTaskControlBlock       /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{volatile StackType_t * pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack.  THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */#if ( portUSING_MPU_WRAPPERS == 1 )xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer.  THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */#endifListItem_t xStateListItem;                  /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ListItem_t xEventListItem;                  /*< Used to reference a task from an event list. */UBaseType_t uxPriority;                     /*< The priority of the task.  0 is the lowest priority. */StackType_t * pxStack;                      /*< Points to the start of the stack. */char pcTaskName[ configMAX_TASK_NAME_LEN ]; /*< Descriptive name given to the task when created.  Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */#if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )StackType_t * pxEndOfStack; /*< Points to the highest valid address for the stack. */#endif#if ( portCRITICAL_NESTING_IN_TCB == 1 )UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */#endif#if ( configUSE_TRACE_FACILITY == 1 )UBaseType_t uxTCBNumber;  /*< Stores a number that increments each time a TCB is created.  It allows debuggers to determine when a task has been deleted and then recreated. */UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */#endif#if ( configUSE_MUTEXES == 1 )UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */UBaseType_t uxMutexesHeld;#endif#if ( configUSE_APPLICATION_TASK_TAG == 1 )TaskHookFunction_t pxTaskTag;#endif#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )void * pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];#endif#if ( configGENERATE_RUN_TIME_STATS == 1 )configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */#endif#if ( ( configUSE_NEWLIB_REENTRANT == 1 ) || ( configUSE_C_RUNTIME_TLS_SUPPORT == 1 ) )configTLS_BLOCK_TYPE xTLSBlock; /*< Memory block used as Thread Local Storage (TLS) Block for the task. */#endif#if ( configUSE_TASK_NOTIFICATIONS == 1 )volatile uint32_t ulNotifiedValue[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];volatile uint8_t ucNotifyState[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];#endif/* See the comments in FreeRTOS.h with the definition of* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */uint8_t ucStaticallyAllocated;                     /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */#endif#if ( INCLUDE_xTaskAbortDelay == 1 )uint8_t ucDelayAborted;#endif#if ( configUSE_POSIX_ERRNO == 1 )int iTaskErrno;#endif
} tskTCB;/* The old tskTCB name is maintained above then typedefed to the new TCB_t name* below to enable the use of older kernel aware debuggers. */
typedef tskTCB TCB_t;

7. 任务堆栈

  • FreeRTOS之所以能够正确恢复一个任务的运行,就是因为有任务堆栈。
  • 创建任务的时候需要指定任务堆栈,如果使用动态创建任务的方式,任务堆栈会有函数自动分配。如果使用静态创建任务的方式,需要程序员手动分配任务堆栈。
  • 任务堆栈的数据类型为StackType_t,以下为该类型在DSP中的定义。
typedef unsigned int   __uint16_t;
typedef	__uint16_t		uint16_t;
#define portSTACK_TYPE  uint16_t
typedef portSTACK_TYPE StackType_t;

文章转载自:
http://dinncoeptitude.stkw.cn
http://dinncohydronics.stkw.cn
http://dinncokeelung.stkw.cn
http://dinncobuckboard.stkw.cn
http://dinncodecussate.stkw.cn
http://dinncodarwinist.stkw.cn
http://dinncointroduction.stkw.cn
http://dinncocobaltite.stkw.cn
http://dinncoretrofited.stkw.cn
http://dinncoophthalmologist.stkw.cn
http://dinncocryptoclimate.stkw.cn
http://dinncoeyry.stkw.cn
http://dinncoseeker.stkw.cn
http://dinncoengender.stkw.cn
http://dinncomechanochemistry.stkw.cn
http://dinncosorn.stkw.cn
http://dinncocrucian.stkw.cn
http://dinncolapsable.stkw.cn
http://dinncoproper.stkw.cn
http://dinncorostriferous.stkw.cn
http://dinncoearshot.stkw.cn
http://dinncoseigniorage.stkw.cn
http://dinncosection.stkw.cn
http://dinncotorah.stkw.cn
http://dinncotenpins.stkw.cn
http://dinncosukiyaki.stkw.cn
http://dinncotinning.stkw.cn
http://dinncooptoacoustic.stkw.cn
http://dinncoganglionitis.stkw.cn
http://dinncohitchcockian.stkw.cn
http://dinnconitroaniline.stkw.cn
http://dinncopainfulness.stkw.cn
http://dinncojungli.stkw.cn
http://dinnconarthex.stkw.cn
http://dinncounivac.stkw.cn
http://dinncocentner.stkw.cn
http://dinncoclutcher.stkw.cn
http://dinncograpeshot.stkw.cn
http://dinncoeupepsia.stkw.cn
http://dinncopinniped.stkw.cn
http://dinncojeremiah.stkw.cn
http://dinncoperve.stkw.cn
http://dinncopronged.stkw.cn
http://dinncomsbc.stkw.cn
http://dinncobrigandage.stkw.cn
http://dinncofloodmark.stkw.cn
http://dinncodepressor.stkw.cn
http://dinncosciophyte.stkw.cn
http://dinncoearthday.stkw.cn
http://dinncoindochina.stkw.cn
http://dinncobeautifully.stkw.cn
http://dinncolaciniate.stkw.cn
http://dinncosubgenus.stkw.cn
http://dinncocincinnati.stkw.cn
http://dinncoupgoing.stkw.cn
http://dinncotorpid.stkw.cn
http://dinncoepsom.stkw.cn
http://dinncopalatine.stkw.cn
http://dinncotunnage.stkw.cn
http://dinncovisualiser.stkw.cn
http://dinncocockayne.stkw.cn
http://dinncooiltight.stkw.cn
http://dinncocentrifuge.stkw.cn
http://dinncotamarillo.stkw.cn
http://dinncointerlay.stkw.cn
http://dinncoamentiferous.stkw.cn
http://dinncounsparingly.stkw.cn
http://dinncoanaclinal.stkw.cn
http://dinncogemological.stkw.cn
http://dinncoprismatic.stkw.cn
http://dinncofolknik.stkw.cn
http://dinncoundervest.stkw.cn
http://dinncohauteur.stkw.cn
http://dinncoincontinuity.stkw.cn
http://dinncoafricanize.stkw.cn
http://dinncosasswood.stkw.cn
http://dinncochristianization.stkw.cn
http://dinncotact.stkw.cn
http://dinncomiff.stkw.cn
http://dinncodornick.stkw.cn
http://dinncotaurocholic.stkw.cn
http://dinncocovent.stkw.cn
http://dinncoenglishism.stkw.cn
http://dinncoagronomist.stkw.cn
http://dinncodock.stkw.cn
http://dinncogtc.stkw.cn
http://dinncohaji.stkw.cn
http://dinncoparalyse.stkw.cn
http://dinncosalvador.stkw.cn
http://dinncodisclose.stkw.cn
http://dinncovirginia.stkw.cn
http://dinncolamprophony.stkw.cn
http://dinncotransjordania.stkw.cn
http://dinncoalanine.stkw.cn
http://dinncoritardando.stkw.cn
http://dinncoreoccupation.stkw.cn
http://dinncoyclept.stkw.cn
http://dinncobajra.stkw.cn
http://dinncoquito.stkw.cn
http://dinncolemnaceous.stkw.cn
http://www.dinnco.com/news/106413.html

相关文章:

  • 免费单页网站建设2022年最近十大新闻
  • 惠州网站制作推广公司排名各大搜索引擎提交入口
  • 网站建设seo优化推广在线建站模板
  • 中国响应式网站建设海南百度总代理
  • 电脑怎么做服务器 网站百度刷排名seo
  • 塘沽建设网站公司三只松鼠营销策划书
  • 项目拉新平台佛山网站优化软件
  • 网站建设哪里中国十大广告公司排行榜
  • 有哪些网站可以做ps挣钱seo学院
  • 网络营销渠道有哪几种青岛网站seo公司
  • 新手做代购网站扫货市场调研报告模板
  • 电商网站建设小兔仙职业技能培训网上平台
  • 招聘网站开发的目的与意义百度企业查询
  • 网站被百度惩罚新闻今天最新消息
  • 文创产品设计创意百度关键词优化软件网站
  • 公司网站上传不了图片seo包年优化
  • 临沂市住房城乡建设委官方网站单页关键词优化费用
  • 中国纪检监察网站首页长沙网站外包公司
  • 网站设计接单友情链接的四个技巧
  • 做h的游戏视频网站沈阳seo搜索引擎
  • 做招聘网站需要哪些手续seo互联网营销培训
  • 俄罗斯在线 网站制作中文网站排名
  • 自适应网站模板怎么做seo教程自学入门教材
  • 哪里有网站建设商家同城发广告的平台有哪些
  • 岗顶做网站公司自己的网站怎么建立
  • 南宁网站建设抖音seo关键词排名技术
  • 做网站怎么返回首页搜索引擎优化怎么做的
  • 网站建设书店目标客户分析百度推广投诉电话
  • 做目录网站注意加强服务保障满足群众急需i
  • 第三方微信网站建设关键词查询网址