Configure RTX v5
The file "RTX_Config.h" defines the configuration parameters of CMSIS-RTOS RTX and must be part of every project that is using the CMSIS-RTOS RTX kernel. The configuration options are explained in detail in the following sections:
System Configuration covers system-wide settings for the global memory pool, tick frequency, ISR event buffer and round-robin thread switching.
Thread Configuration provides several parameters to configure the Thread Management functions.
Timer Configuration provides several parameters to configure the Timer Management functions.
Event Flags Configuration provides several parameters to configure the Event Flags functions.
Mutex Configuration provides several parameters to configure the Mutex Management functions.
Semaphore Configuration provides several parameters to configure the Semaphores functions.
Memory Pool Configuration provides several parameters to configure the Memory Pool functions.
Message Queue Configuration provides several parameters to configure the Message Queue functions.
Event Recorder Configuration provides several parameters to configure RTX for usage with Event Recorder.
The file "RTX_Config.c" contains default implementations of the functions osRtxIdleThread and osRtxErrorNotify. Both functions can simply be overwritten with a customized behavior by redefining them as part of the user code.
The configuration file uses Configuration Wizard Annotations. Refer to Pack - Configuration Wizard Annotations for details. Depending on the development tool, the annotations might lead to a more user-friendly graphical
representation of the settings. The picture below shows the µVision Configuration Wizard view in MDK:
RTX_Config.h in Configuration Wizard View
Alternatively one can provide configuration options using the compiler command line.
For example one can customize the used tick frequency to 100us by (overwriting) the configuration using
cc -DOS_TICK_FREQ=100
System Configuration
The system configuration covers system-wide settings for the global memory pool, tick frequency, ISR event buffer and round-robin thread switching.
System Configuration Options
RTX_Config.h: System Configuration
Name #define Description
Global Dynamic Memory size [bytes]
OS_DYNAMIC_MEM_SIZE
Defines 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.
Kernel Tick Frequency (Hz)
OS_TICK_FREQ
Defines base time unit for delays and timeouts in Hz. Default: 1000Hz = 1ms period.
Round-Robin Thread switching
OS_ROBIN_ENABLE
Enables Round-Robin Thread switching.
Round-Robin Timeout
OS_ROBIN_TIMEOUT
Defines how long a thread will execute before a thread switch. Default value is 5. Value range is [1-1000].
ISR FIFO Queue
OS_ISR_FIFO_QUEUE
RTOS Functions called from ISR store requests to this buffer. Default value is 16 entries. Value range is [4-256] entries in multiples of 4.
Object Memory usage counters
OS_OBJ_MEM_USAGE
Enables object memory usage counters to evaluate the maximum memory pool requirements individually for each RTOS object type.
Global dynamic memory
Refer to Global Memory Pool.
Round-Robin Thread Switching
RTX5 may be configured to use round-robin multitasking thread switching. Round-robin allows quasi-parallel execution of several threads of the same priority. Threads are not really executed concurrently, but are scheduled where the
available CPU time is divided into time slices and RTX5 assigns a time slice to each thread. Because the time slice is typically short (only a few milliseconds), it appears as though threads execute simultaneously.
Round-robin thread switching functions as follows:
the tick is preloaded with the timeout value when a thread switch occurs
the tick is decremented (if not already zero) each system tick if the same thread is still executing
when the tick reaches 0 it indicates that a timeout has occurred. If there is another thread ready with the same priority, then the system switches to that thread and the tick is preloaded with timeout again.
In other words, threads execute for the duration of their time slice (unless a thread's time slice is given up). Then, RTX switches to the next thread that is in READY state and has the same priority. If no other thread with the same
priority is ready to run, the current running thread resumes it execution.
Note
When switching to higher priority threads, the round-robin timeout value is reset.
Round-Robin multitasking is controlled with the #define OS_ROBIN_ENABLE. The time slice period is configured (in RTX timer ticks) with the #define OS_ROBIN_TIMEOUT.
ISR FIFO Queue
The RTX functions (Calls from Interrupt Service Routines), when called from and interrupt handler, store the request type and optional parameter to the ISR FIFO queue buffer to be processed later, after the interrupt handler exits.
The scheduler is activated immediately after the IRQ handler has finished its execution to process the requests stored to the FIFO queue buffer. The required size of this buffer depends on the number of functions that are called within the
interrupt handler. An insufficient queue size will be caught by osRtxErrorNotify with error code osRtxErrorISRQueueOverflow.
Object Memory Usage Counters
Object memory usage counters help to evaluate the maximum memory pool requirements for each object type, just like stack watermarking does for threads. The initial setup starts with a global memory pool for all object types.
Consecutive runs of the application with object memory usage counters enabled, help to introduce object specific memory pools for each object type. Normally, this is required for applications that require a functional safety certification as
global memory pools are not allowed in this case.
Thread Configuration
The RTX5 provides several parameters to configure the Thread Management functions.
Thread Configuration Options
RTX_Config.h: Thread Configuration
Option #define Description
Object specific Memory allocation
OS_THREAD_OBJ_MEM
Enables object specific memory allocation. See Object-specific Memory Pools.
Number of user Threads
OS_THREAD_NUM
Defines maximum number of user threads that can be active at the same time. Applies to user threads with system provided memory for control