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

RTX5 | 配置文件RTX_Config.h

文章目录

  • 一、前言
  • 二、System Configuration(系统设置)
    • 2.1、Global Dynamic memory size(内存池的大小)
    • 2.2、Kernel Tick Frequency[Hz](内核滴答时钟的频率)
    • 2.3、Round-Robin Thread switching(时间片轮转调度)
    • 2.4、ISR FIFO Queue(中断回调请求FIFO队列)
    • 2.5、Object Memory usage counters(对象内存使用计数器)
  • 三、Thread Configuration
    • 3.1、Object specific Memory allocation(对象特定的内存分配)
      • 3.1.1、Number of user Threads(用户线程的数量)
      • 3.1.2、Number of user Threads with default Stack size(使用默认堆栈大小的用户线程的数量)
      • 3.1.3、Total Stack size[bytes] for user Threads with user-provided Stack size(提供给用户线程的总堆栈大小)
    • 3.2、Default Thread Stack size(线程的默认堆栈大小)
    • 3.3、Idle Thread Stack size(空闲线程的堆栈大小)
    • 3.4、Idle Thread TrustZone Module Identifier(空闲线程信任区域模块标识符)
    • 3.5、Stack overrun checking (堆栈溢出检查)
    • 3.6、Stack usage watermark(堆栈使用水印)
    • 3.7、Processor mode for Thread execution(线程执行的处理器模式)
  • 四、Timer Configuration (时钟配置)
    • 4.1、Object specific Memory allocation(对象特定的内存分配)
    • 4.2、Timer Thread Priority(软件定时器的优先级)
    • 4.3、Timer Thread Stack size[bytes]
    • 4.4、Timer Thread TrustZone Module Identifier
    • 4.5、Timer Callback Queue entries(定时器回调消息队列)
  • 五、Event Flags Configuration(事件标志配置)
    • 5.1 Object-specific memory allocation(Event Flags 的对象特定内存分配)
  • 六、Mutex Configuration
    • 5.1 Object-specific Memory Allocation(互斥量 的对象特定内存分配)
  • 七、Semaphore Configuration
  • 八、Memory Pool Configuration
  • 九、Message Queue Configuration
  • 十、Event Recorder Configuration

一、前言

  使用RTX5开发项目之前,一定要先把RTX5系统配置文件RTX_Config.h弄明白。

  • RTX_Congig.h包含以下内容:
  1. System Configuration(非常重要)
  2. Thread Configuration(非常重要)
  3. Timer Configuration(简单)
  4. Event Flags Configuration(简单)
  5. Mutex Configuration(简单)
  6. Semaphore Configuration(简单)
  7. Memory Pool Configuration(简单)
  8. Event Record Configuration(跟RTX5内核没关系,调试工具)
    在这里插入图片描述

二、System Configuration(系统设置)

在这里插入图片描述
在这里插入图片描述

Name#defineDescription
Global Dynamic Memory size [bytes]OS_DYNAMIC_MEM_SIZEDefines the combined global dynamic memory size for the Global Memory Pool. Default value is 4096. Value range is [0-1073741824] bytes, in multiples of 8 bytes.(为全局内存池(Global Memory Pool)定义全局动态内存大小。默认值是4096。值范围为[0-1073741824]字节,为8字节的倍数)
Kernel Tick Frequency (Hz)OS_TICK_FREQDefines base time unit for delays and timeouts in Hz. Default: 1000Hz = 1ms period.(系统节拍的频率,决定了时间片的最小计量单元,单位HZ。1000H=1ms的同期。)
Round-Robin Thread switchingOS_ROBIN_ENABLEEnables Round-Robin Thread switching.(选择是否使能循环调度)
Round-Robin TimeoutOS_ROBIN_TIMEOUTDefines how long a thread will execute before a thread switch. Default value is 5. Value range is [1-1000].(表示时间片的大小,单位是系统时钟节拍个数。默认值是5。取值范围为[1-1000].)
ISR FIFO QueueOS_ISR_FIFO_QUEUERTOS Functions called from ISR store requests to this buffer. Default value is 16 entries. Value range is [4-256] entries in multiples of 4.(表示ISR FIFO队列大小。中新服务程序中调用以isr_开头的函数时,会将请求类型存到此缓冲中。默以值是16个条目(entries)。值范围是[4-256],4的倍数。)
Object Memory usage countersOS_OBJ_MEM_USAGEEnables object memory usage counters to evaluate the maximum memory pool requirements individually for each RTOS object type.(使能对象内存使用计数器,用于单独计算每个RTOS对象类型的最大内存池需求。)

2.1、Global Dynamic memory size(内存池的大小)

在这里插入图片描述
  内存池的大小默认值是32768个字节,相当于32K的RAM内存。

2.2、Kernel Tick Frequency[Hz](内核滴答时钟的频率)

在这里插入图片描述
  总的来说,就是提供时间基准给osDelay( )osDelayUntil( ),还有超时计算。 Kernel Tick Frequency频率越高就更占用CPU的资源,一般项目直接使用1000Hz即可。

2.3、Round-Robin Thread switching(时间片轮转调度)

在这里插入图片描述
  总的来说,就是RTX5也提供时间片轮转调度的功能。 有了这个功能后,系统就允许有两个以上的线程使用同一个优先级。为同一个优先级下的线程划分时间片进行调度,时间片的长度可以通过Round-Robin Timeout设置(5等于5个Tick)。
  时间片轮转调度适用于不要求任务实时响应的情况。 我的实际项目都是工业控制机器人控制,对实时性都有要求。所以,一般我都会禁止时间片轮转调度功能,取消勾选Round-Robin Thread switching这个选项。我的项目都是使用抢占式的方式进行调度(各个线程的优先级不一样)。

2.4、ISR FIFO Queue(中断回调请求FIFO队列)

在这里插入图片描述
  总的来说,RTX5能缓存Cortex-M内核的中断回调函数ISR的请求与参数。

2.5、Object Memory usage counters(对象内存使用计数器)

在这里插入图片描述
  总得来说,就是在系统运行的过程中,计算线程,消息队列等对象的生存情况。 上面英文的最后一句话很重要,中文意思:对于需要安全性认真的应用程序来说,这个功能是必需的。勾选这个选项后,通过DEBUG模式下的RTX RTOS调试窗口可以看到Object Memory Usage Counter选项。

三、Thread Configuration

在这里插入图片描述

Option#defineDescription
Object specific Memory allocationOS_THREAD_OBJ_MEMEnables object specific memory allocation. See Object-specific Memory Pools.(是否启用对象特定内存分配。)
Number of user ThreadsOS_THREAD_NUMDefines maximum number of user threads that can be active at the same time. Applies to user threads with system provided memory for control blocks. Default value is 1. Value range is [1-1000].(定义可以同时运行的最大用户线程数。适用于系统为控制块提供内存的用户线程。默认值是1。值范围是[1-1000])
Number of user Threads with default Stack sizeOS_THREAD_DEF_STACK_NUMDefines maximum number of user threads with default stack size and applies to user threads with 0 stack size specified. Value range is [0-1000].(定义使用默认堆栈大小的线程数,取0则表示所有线程都不使用默认大小而使用自定义堆栈大小。取值范围为0-1000]。)
Total Stack size [bytes] for user Threads with user-provided Stack sizeOS_THREAD_USER_STACK_SIZEDefines the combined stack size for user threads with user-provided stack size. Default value is 0. Value range is [0-1073741824] Bytes, in multiples of 8.(用户自定义堆栈大小的用户线程的总堆栈大小字节)。默认值为0.值范国为0-1073741824]字节,为8的倍数。)
Default Thread Stack size [bytes]OS_STACK_SIZEDefines stack size for threads with zero stack size specified. Default value is 200. Value range is [96-1073741824] Bytes, in multiples of 8.(默认线程堆栈的大小,用户未提供堆栈大小时使用此参数。默认值是200。值范国为96-1073741824]字节,为8的倍数。)
Idle Thread Stack size [bytes]OS_IDLE_THREAD_STACK_SIZEDefines stack size for Idle thread. Default value is 200. Value range is [72-1073741824] bytes, in multiples of 8.(定义空闲线程的堆栈大小。默认值是200。值范国为[72-1073741824]字节,以8为倍数。)
Idle Thread TrustZone Module IDOS_IDLE_THREAD_TZ_MOD_IDDefines the TrustZone Module ID the Idle Thread shall use. This needs to be set to a non-zero value if the Idle Thread need to call secure functions. Default value is 0.(定义空闲线程应该使用的TrustZone Module ID。如果空闲线程需要调用安全函数,则需要将该值设置为非零值。默认值为0.)
Stack overrun checkingOS_STACK_CHECKEnable stack overrun checks at thread switch.(启用线程切换处的堆栈溢出检查。)
Stack usage watermarkOS_STACK_WATERMARKInitialize thread stack with watermark pattern for analyzing stack usage. Enabling this option increases significantly the execution time of thread creation.(使用水印模式初始化线程堆栈,以分析堆栈使用情况。启用此选项会显著增加线程创建的执行时间。)
Processor mode for Thread executionOS_PRIVILEGE_MODEControls the processor mode. Default value is Privileged mode. Value range is [0=Unprivileged; 1=Privileged] mode.(选择处理器模式。默认值是特权模式。取值范围为[0=无特权;1=特权)模式。)

3.1、Object specific Memory allocation(对象特定的内存分配)

在这里插入图片描述
  Object specific Memory allocation为每一个RTX5的对象创建一个专用的固定大小的内存块,可以有效防止内存碎片化,并简化内存不足情况的处理。并且,在专用的内存里创建对象与删除对象的时间都是完全确定的。
在这里插入图片描述
  默认的配置下,不勾选Object Specific Memory allocation。此时,当我们创建RTX5的对象时,会在全局内存池里申请一段内存。有线程对象,有消息队列对象,有信号量对象等等,按申请内存的时间顺序一个个放入Global Memory Pool(全局内存池)里。这种情况下,内存肯定会有一点乱。
在这里插入图片描述

3.1.1、Number of user Threads(用户线程的数量)

  定义同一时间上最多可以运行多少个用户线程。实际测试一下,当前我的程序创建了4个线程。接着,我将Number of user Thread设置3,看看效果如何。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.1.2、Number of user Threads with default Stack size(使用默认堆栈大小的用户线程的数量)

  系统的默认是3072Byte。不建议使用默认的堆栈大小,每一个线程都应该有合适的内存大小。
在这里插入图片描述

3.1.3、Total Stack size[bytes] for user Threads with user-provided Stack size(提供给用户线程的总堆栈大小)

  使用默认值0,应该是不设置的意思。(毕竟,我一直使用默认值0也能顺利创建多个线程)
在这里插入图片描述

3.2、Default Thread Stack size(线程的默认堆栈大小)

  创建线程时不指定堆栈大小,就会使用Default Thread Stack Size的值来创建线程。
在这里插入图片描述

3.3、Idle Thread Stack size(空闲线程的堆栈大小)

  看空闲线程的设计需要多大的内存,默认的空闲线程只需256KB。
在这里插入图片描述

3.4、Idle Thread TrustZone Module Identifier(空闲线程信任区域模块标识符)

  Armv8-M/v8.1-M架构的单片机才有。
在这里插入图片描述

3.5、Stack overrun checking (堆栈溢出检查)

  一定要勾选,堆栈真的很容易溢出。

3.6、Stack usage watermark(堆栈使用水印)

  使用水印模式初始化线程堆栈以分析堆栈使用情况。 启用此选项会显着增加线程创建的执行时间。我觉得没必要勾选这一项,在DEBUG模式下,使用Keil的RTX RTOS也能看到堆栈的使用情况。
在这里插入图片描述

3.7、Processor mode for Thread execution(线程执行的处理器模式)

必须使用privileged mode,不然功能可能会受到限制:
在这里插入图片描述

四、Timer Configuration (时钟配置)

在这里插入图片描述

Name#defineDescription
Object specific Memory allocationOS_TIMER_OBJ_MEMEnables object specific memory allocation.(使能对象特定内存分配)
Number of Timer objectsOS_TIMER_NUMDefines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is [1-1000].(代表可以同时运行的最大用户定时器数。适用于系统为控制块提供内存的用户定时器。默认值是1。值范围是[1-1000].)
Timer Thread PriorityOS_TIMER_THREAD_PRIODefines priority for timer thread. Default value is 40. Value range is [8-48], in multiples of 8. The numbers have the following priority correlation: 8=Low; 16=Below Normal; 24=Normal; 32=Above Normal; 40=High; 48=Realtime(表示定时器线程的优先级。默认值是40。取值范围为[8-48],取8的倍数。这些数字的优先级相关如下:8=低, 16=低于正常,24=正常, 32=高于正常, 40=高, 48=实时)
Timer Thread Stack size [bytes]OS_TIMER_THREAD_STACK_SIZEDefines stack size for Timer thread. May be set to 0 when timers are not used. Default value is 200. Value range is [0-1073741824], in multiples of 8.(定义计时器线程的堆栈大小。当不使用计时器时,可以将其设置为0。默认值是200。取值范围为[0-1073741824],取8的倍数。)
Timer Thread TrustZone Module IDOS_TIMER_THREAD_TZ_MOD_IDDefines the TrustZone Module ID the Timer Thread shall use. This needs to be set to a non-zero value if any Timer Callbacks need to call secure functions. Default value is 0.(定时器回调函数可以同时运行的最大数目。当不使用计时器时,可以将其设置为0。默认值是4。取值范围为[0-256]。)
Timer Callback Queue entriesOS_TIMER_CB_QUEUENumber of concurrent active timer callback functions. May be set to 0 when timers are not used. Default value is 4. Value range is [0-256].(定义空闲线程应该使用的TrustZone Module ID。如果空闲线程需要调用安全函数,则需要将该值设置为非零值。默认值为0.)

从RTX_Config.h的配置与创建软件定时器的API函数可以得到以下信息:

  1. 软件定时器的优先级在RTX_Config.h上设置,且软件定时器的API函数不能设置定时器的优先级(线程的优先级由线程API函数设置的)。
  2. 同一个工程上,所有软件定时器的优先级只能一样了(每一个线程可以设置不同的优先级)。
  3. 同一个工程上,所有软件定时器的堆栈大小也只能一样了(每一个线程可以设置不同的堆栈大小)。

4.1、Object specific Memory allocation(对象特定的内存分配)

在这里插入图片描述
  跟线程上的Object specific Memory allocation一样。

4.2、Timer Thread Priority(软件定时器的优先级)

在这里插入图片描述
软件定时器只支持6种优先级:

  1. Low
  2. Below Normal
  3. Normal
  4. Above Normal
  5. High
  6. Real Time

4.3、Timer Thread Stack size[bytes]

在这里插入图片描述
  设置每一个软件定时器的堆栈大小。

4.4、Timer Thread TrustZone Module Identifier

  特定的Cortex-M内核才有,STM32F407与STM32H743与STM32F103都没有这个功能。

4.5、Timer Callback Queue entries(定时器回调消息队列)

  设置定时器并发回调函数的数量,设置0时,关闭此功能。

五、Event Flags Configuration(事件标志配置)

RTX5提供了几个参数来配置 事件标志(Event Flags) 功能。
在这里插入图片描述

Name#defineDescription
Object specific Memory allocationOS_EVFLAGS_OBJ_MEMEnables object specific memory allocation. See Object-specific Memory Pools.(启用对象特定的内存分配)
Number of Event Flags objectsOS_EVFLAGS_NUMDefines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is [1-1000].(定义同时活跃的最大事件标记数。适用于系统为控制块提供内存的控制块。取值范围为[1-1000]。)

5.1 Object-specific memory allocation(Event Flags 的对象特定内存分配)

当使用对象特定内存时,所有 事件标记对象(Event object) 的内存池大小OS_EVFLAGS_NUM指定。

六、Mutex Configuration

RTX5提供了几个参数来配置互斥量(Mutex)功能。
在这里插入图片描述

Name#defineDescription
Object specific Memory allocationOS_MUTEX_OBJ_MEMEnables object specific memory allocation. See Object-specific Memory Pools.(启用特定于对象的内存分配。)
Number of Mutex objectsOS_MUTEX_NUMDefines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is [1-1000].(定义可以同时活动的对象的最大数量。应用于具有系统为控制块提供内存的对象。取值范围为[1 ~ 1000]。)

5.1 Object-specific Memory Allocation(互斥量 的对象特定内存分配)

当使用对象特定内存时,所有 互斥量对象(Mutex object) 的内存池大小由 OS_MUTEX_NUM 指定。

七、Semaphore Configuration

在这里插入图片描述
在这里插入图片描述

八、Memory Pool Configuration

在这里插入图片描述
在这里插入图片描述

九、Message Queue Configuration

在这里插入图片描述
在这里插入图片描述

十、Event Recorder Configuration

http://www.lqws.cn/news/469099.html

相关文章:

  • 借助ChatGPT快速开发图片转PDF的Python工具
  • 从0开始学习R语言--Day28--高维回归
  • 大学专业解读——电气,自动化,仪器
  • ZooKeeper 3.9.2 集群安装指南
  • AIGC工具平台-Duix.Heygem音频对口型数字人
  • API网关Apisix管理接口速查
  • Mac电脑-触摸板增强工具-BetterTouchTool
  • SpringAI1.0.0 入门案例
  • LLM:重构数字世界的“智能操作系统”
  • 71、单元测试-Junit5简介
  • Transformer架构每层详解【代码实现】
  • 使用Trae编辑器与MCP协议构建高德地图定制化服务
  • 【unity】批量剔除图片四周空白像素的工具
  • 深入Java大厂面试:从Spring框架到微服务架构的技术解析
  • python web开发-Flask数据库集成
  • 深度剖析 PACK_SESSIONID 实现原理与安全突破机制
  • 分组交换比报文交换的传输时延更低
  • 深入剖析Linux epoll模型:从LT/ET模式到EPOLLONESHOT的实战指南
  • 【Linux】线程概念 分页式存储 优缺点
  • 开源Blazor界面组件库:Ant Design Blazor
  • 【全开源】填表问卷统计预约打卡表单系统+uniapp前端
  • ESP32 ESP-IDF Ubuntu平台工具链的标准设置
  • 百度萝卜快跑携4颗禾赛激光雷达进军迪拜,千辆L4无人车开启全球化战略
  • 华为云Flexus+DeepSeek征文 | AingDesk 对接华为云 ModelArts Studio 全流程教程与性能测评对比
  • 基于 Flutter+Sqllite 实现大学个人课表助手 APP(期末作业)
  • 【Docker 08】Compose - 容器编排
  • 【AGI】突破感知-决策边界:VLA-具身智能2.0
  • Node.js特训专栏-实战进阶:5. Express路由系统设计与优化
  • [幻灯片]分析设计高阶-02结构05-202506更新-GJ-002
  • 【Memory协议栈】Autosar架构下如何测量Fee的切页时间