CMSIS-RTOS2: rtx_os.h File Reference

| CMSIS-RTOS2 Version 2.1.3 Real-Time Operating System: API and RTX Reference Implementation

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
rtx_os.h File Reference

## Data Structures
struct | osRtxThread_t
| Thread Control Block. More...
struct | osRtxTimerFinfo_t
| Timer Function Information. More...
struct | osRtxTimer_t
| Timer Control Block. More...
struct | osRtxEventFlags_t
| Event Flags Control Block. More...
struct | osRtxMutex_t
| Mutex Control Block. More...
struct | osRtxSemaphore_t
| Semaphore Control Block. More...
struct | osRtxMpInfo_t
| Memory Pool Information. More...
struct | osRtxMemoryPool_t
| Memory Pool Control Block. More...
struct | osRtxMessage_t
| Message Control Block. More...
struct | osRtxMessageQueue_t
| Message Queue Control Block. More...
struct | osRtxObject_t
| Generic Object Control Block. More...
struct | osRtxInfo_t
| OS Runtime Information structure. More...
struct | osRtxObjectMemUsage_t
| OS Runtime Object Memory Usage structure. More...
struct | osRtxConfig_t
| OS Configuration structure. More...
struct | osRtxInfo_t.kernel
struct | osRtxInfo_t.thread
struct | osRtxInfo_t.thread.run
| < Thread Info More...
struct | osRtxInfo_t.thread.robin
struct | osRtxInfo_t.timer
struct | osRtxInfo_t.isr_queue
struct | osRtxInfo_t.post_process
struct | osRtxInfo_t.mem
struct | osRtxInfo_t.mpi
struct | osRtxConfig_t.isr_queue
struct | osRtxConfig_t.mem
struct | osRtxConfig_t.mpi

## Macros
#define | osRtxVersionAPI 20010003
| Kernel Information. More...
#define | osRtxVersionKernel 50040000
| Kernel version (5.4.0) More...
#define | osRtxKernelId "RTX V5.4.0"
| Kernel identification string. More...
#define | osRtxIdInvalid 0x00U
| Object Identifier definitions. More...
#define | osRtxIdThread 0x01U
#define | osRtxIdTimer 0x02U
#define | osRtxIdEventFlags 0x03U
#define | osRtxIdMutex 0x04U
#define | osRtxIdSemaphore 0x05U
#define | osRtxIdMemoryPool 0x06U
#define | osRtxIdMessage 0x07U
#define | osRtxIdMessageQueue 0x08U
#define | osRtxFlagSystemObject 0x01U
| Object Flags definitions. More...
#define | osRtxFlagSystemMemory 0x02U
#define | osRtxKernelInactive ((uint8_t)osKernelInactive)
| Kernel State definitions. More...
#define | osRtxKernelReady ((uint8_t)osKernelReady)
#define | osRtxKernelRunning ((uint8_t)osKernelRunning)
#define | osRtxKernelLocked ((uint8_t)osKernelLocked)
#define | osRtxKernelSuspended ((uint8_t)osKernelSuspended)
#define | osRtxThreadStateMask 0x0FU
| Thread State definitions (extending osThreadState) More...
#define | osRtxThreadInactive ((uint8_t)osThreadInactive)
#define | osRtxThreadReady ((uint8_t)osThreadReady)
#define | osRtxThreadRunning ((uint8_t)osThreadRunning)
#define | osRtxThreadBlocked ((uint8_t)osThreadBlocked)
#define | osRtxThreadTerminated ((uint8_t)osThreadTerminated)
#define | osRtxThreadWaitingDelay ((uint8_t)(osRtxThreadBlocked | 0x10U))
#define | osRtxThreadWaitingJoin ((uint8_t)(osRtxThreadBlocked | 0x20U))
#define | osRtxThreadWaitingThreadFlags ((uint8_t)(osRtxThreadBlocked | 0x30U))
#define | osRtxThreadWaitingEventFlags ((uint8_t)(osRtxThreadBlocked | 0x40U))
#define | osRtxThreadWaitingMutex ((uint8_t)(osRtxThreadBlocked | 0x50U))
#define | osRtxThreadWaitingSemaphore ((uint8_t)(osRtxThreadBlocked | 0x60U))
#define | osRtxThreadWaitingMemoryPool ((uint8_t)(osRtxThreadBlocked | 0x70U))
#define | osRtxThreadWaitingMessageGet ((uint8_t)(osRtxThreadBlocked | 0x80U))
#define | osRtxThreadWaitingMessagePut ((uint8_t)(osRtxThreadBlocked | 0x90U))
#define | osRtxThreadFlagDefStack 0x10U
| Thread Flags definitions. More...
#define | osRtxStackMagicWord 0xE25A2EA5U
| Stack Marker definitions. More...
#define | osRtxStackFillPattern 0xCCCCCCCCU
| Stack Fill Pattern. More...
#define | osRtxTimerInactive 0x00U
| Timer State definitions. More...
#define | osRtxTimerStopped 0x01U
| Timer Stopped. More...
#define | osRtxTimerRunning 0x02U
| Timer Running. More...
#define | osRtxTimerPeriodic ((uint8_t)osTimerPeriodic)
| Timer Type definitions. More...
#define | osRtxThreadFlagsLimit 31U
| number of Thread Flags available per thread More...
#define | osRtxEventFlagsLimit 31U
| number of Event Flags available per object More...
#define | osRtxMutexLockLimit 255U
| maximum number of recursive mutex locks More...
#define | osRtxSemaphoreTokenLimit 65535U
| maximum number of tokens per semaphore More...
#define | osRtxThreadCbSize sizeof(osRtxThread_t)
| Thread Control Block size. More...
#define | osRtxTimerCbSize sizeof(osRtxTimer_t)
| Timer Control Block size. More...
#define | osRtxEventFlagsCbSize sizeof(osRtxEventFlags_t)
| Event Flags Control Block size. More...
#define | osRtxMutexCbSize sizeof(osRtxMutex_t)
| Mutex Control Block size. More...
#define | osRtxSemaphoreCbSize sizeof(osRtxSemaphore_t)
| Semaphore Control Block size. More...
#define | osRtxMemoryPoolCbSize sizeof(osRtxMemoryPool_t)
| Memory Pool Control Block size. More...
#define | osRtxMessageQueueCbSize sizeof(osRtxMessageQueue_t)
| Message Queue Control Block size. More...
#define | osRtxMemoryPoolMemSize(block_count, block_size) (4*(block_count)*(((block_size)+3)/4))
| Memory Pool Memory size. More...
#define | osRtxMessageQueueMemSize(msg_count, msg_size) (4*(msg_count)*(3+(((msg_size)+3)/4)))
| Message Queue Memory size. More...
#define | osRtxErrorStackUnderflow 1U
| Stack overflow, i.e. stack pointer below its lower memory limit for descending stacks. More...
#define | osRtxErrorISRQueueOverflow 2U
| ISR Queue overflow detected when inserting object. More...
#define | osRtxErrorTimerQueueOverflow 3U
| User Timer Callback Queue overflow detected for timer. More...
#define | osRtxErrorClibSpace 4U
| Standard C/C++ library libspace not available. More...
#define | osRtxErrorClibMutex 5U
| Standard C/C++ library mutex initialization failed. More...
#define | osRtxConfigPrivilegedMode (1UL<<0)
| OS Trusted Firmware M Extension. More...
#define | osRtxConfigStackCheck (1UL<<1)
| Stack overrun checking. More...
#define | osRtxConfigStackWatermark (1UL<<2)
| Stack usage Watermark. More...

## Functions
uint32_t | osRtxErrorNotify (uint32_t code, void *object_id)
| OS Error Callback function. More...
void | osRtxIdleThread (void *argument)
| OS Idle Thread. More...
void | SVC_Handler (void)
| OS Exception handlers. More...
void | PendSV_Handler (void)
void | SysTick_Handler (void)

## Variables
osRtxInfo_t | osRtxInfo
| OS Runtime Information. More...
osRtxObjectMemUsage_t | osRtxThreadMemUsage
| OS Runtime Object Memory Usage variables. More...
osRtxObjectMemUsage_t | osRtxTimerMemUsage
osRtxObjectMemUsage_t | osRtxEventFlagsMemUsage
osRtxObjectMemUsage_t | osRtxMutexMemUsage
osRtxObjectMemUsage_t | osRtxSemaphoreMemUsage
osRtxObjectMemUsage_t | osRtxMemoryPoolMemUsage
osRtxObjectMemUsage_t | osRtxMessageQueueMemUsage
const osRtxConfig_t | osRtxConfig
| OS Configuration. More...

## Data Structure Documentation

struct osRtxThread_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | state | Object State.
uint8_t | flags | Object Flags.
uint8_t | attr | Object Attributes.
const char * | name | Object Name.
struct osRtxThread_s * | thread_next | Link pointer to next Thread in Object list.
struct osRtxThread_s * | thread_prev | Link pointer to previous Thread in Object list.
struct osRtxThread_s * | delay_next | Link pointer to next Thread in Delay list.
struct osRtxThread_s * | delay_prev | Link pointer to previous Thread in Delay list.
struct osRtxThread_s * | thread_join | Thread waiting to Join.
uint32_t | delay | Delay Time.
int8_t | priority | Thread Priority.
int8_t | priority_base | Base Priority.
uint8_t | stack_frame | Stack Frame (EXC_RETURN[7..0])
uint8_t | flags_options | Thread/Event Flags Options.
uint32_t | wait_flags | Waiting Thread/Event Flags.
uint32_t | thread_flags | Thread Flags.
struct osRtxMutex_s * | mutex_list | Link pointer to list of owned Mutexes.
void * | stack_mem | Stack Memory.
uint32_t | stack_size | Stack Size.
uint32_t | sp | Current Stack Pointer.
uint32_t | thread_addr | Thread entry address.
uint32_t | tz_memory | TrustZone Memory Identifier.

struct osRtxTimerFinfo_t

Data Fields
osTimerFunc_t | func | Function Pointer.
void * | arg | Function Argument.

struct osRtxTimer_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | state | Object State.
uint8_t | flags | Object Flags.
uint8_t | type | Timer Type (Periodic/One-shot)
const char * | name | Object Name.
struct osRtxTimer_s * | prev | Pointer to previous active Timer.
struct osRtxTimer_s * | next | Pointer to next active Timer.
uint32_t | tick | Timer current Tick.
uint32_t | load | Timer Load value.
osRtxTimerFinfo_t | finfo | Timer Function Info.

struct osRtxEventFlags_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | reserved_state | Object State (not used)
uint8_t | flags | Object Flags.
uint8_t | reserved |
const char * | name | Object Name.
osRtxThread_t * | thread_list | Waiting Threads List.
uint32_t | event_flags | Event Flags.

struct osRtxMutex_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | reserved_state | Object State (not used)
uint8_t | flags | Object Flags.
uint8_t | attr | Object Attributes.
const char * | name | Object Name.
osRtxThread_t * | thread_list | Waiting Threads List.
osRtxThread_t * | owner_thread | Owner Thread.
struct osRtxMutex_s * | owner_prev | Pointer to previous owned Mutex.
struct osRtxMutex_s * | owner_next | Pointer to next owned Mutex.
uint8_t | lock | Lock counter.
uint8_t | padding[3] |

struct osRtxSemaphore_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | reserved_state | Object State (not used)
uint8_t | flags | Object Flags.
uint8_t | reserved |
const char * | name | Object Name.
osRtxThread_t * | thread_list | Waiting Threads List.
uint16_t | tokens | Current number of tokens.
uint16_t | max_tokens | Maximum number of tokens.

struct osRtxMpInfo_t

Data Fields
uint32_t | max_blocks | Maximum number of Blocks.
uint32_t | used_blocks | Number of used Blocks.
uint32_t | block_size | Block Size.
void * | block_base | Block Memory Base Address.
void * | block_lim | Block Memory Limit Address.
void * | block_free | First free Block Address.

struct osRtxMemoryPool_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | reserved_state | Object State (not used)
uint8_t | flags | Object Flags.
uint8_t | reserved |
const char * | name | Object Name.
osRtxThread_t * | thread_list | Waiting Threads List.
osRtxMpInfo_t | mp_info | Memory Pool Info.

struct osRtxMessage_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | reserved_state | Object State (not used)
uint8_t | flags | Object Flags.
uint8_t | priority | Message Priority.
struct osRtxMessage_s * | prev | Pointer to previous Message.
struct osRtxMessage_s * | next | Pointer to next Message.

struct osRtxMessageQueue_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | reserved_state | Object State (not used)
uint8_t | flags | Object Flags.
uint8_t | reserved |
const char * | name | Object Name.
osRtxThread_t * | thread_list | Waiting Threads List.
osRtxMpInfo_t | mp_info | Memory Pool Info.
uint32_t | msg_size | Message Size.
uint32_t | msg_count | Number of queued Messages.
osRtxMessage_t * | msg_first | Pointer to first Message.
osRtxMessage_t * | msg_last | Pointer to last Message.

struct osRtxObject_t

Data Fields
uint8_t | id | Object Identifier.
uint8_t | state | Object State.
uint8_t | flags | Object Flags.
uint8_t | reserved |
const char * | name | Object Name.
osRtxThread_t * | thread_list | Threads List.

struct osRtxInfo_t

Data Fields
const char * | os_id | OS Identification.
uint32_t | version | OS Version.
struct osRtxInfo_t | kernel |
int32_t | tick_irqn | Tick Timer IRQ Number.
struct osRtxInfo_t | thread |
struct osRtxInfo_t | timer |
struct osRtxInfo_t | isr_queue |
struct osRtxInfo_t | post_process |
struct osRtxInfo_t | mem |
struct osRtxInfo_t | mpi |

struct osRtxObjectMemUsage_t

Data Fields
uint32_t | cnt_alloc | Counter for alloc.
uint32_t | cnt_free | Counter for free.
uint32_t | max_used | Maximum used.

struct osRtxConfig_t

Data Fields
uint32_t | flags | OS Configuration Flags.
uint32_t | tick_freq | Kernel Tick Frequency.
uint32_t | robin_timeout | Round Robin Timeout Tick.
struct osRtxConfig_t | isr_queue |
struct osRtxConfig_t | mem |
struct osRtxConfig_t | mpi |
uint32_t | thread_stack_size | Default Thread Stack Size.
const osThreadAttr_t * | idle_thread_attr | Idle Thread Attributes.
const osThreadAttr_t * | timer_thread_attr | Timer Thread Attributes.
const osMessageQueueAttr_t * | timer_mq_attr | Timer Message Queue Attributes.
uint32_t | timer_mq_mcnt | Timer Message Queue maximum Messages.

struct osRtxInfo_t.kernel

Data Fields
uint8_t | state | < Kernel Info State
volatile uint8_t | blocked | Blocked.
uint8_t | pendSV | Pending SV.
uint8_t | reserved |
uint32_t | tick | Tick counter.

struct osRtxInfo_t.thread

Data Fields
thread | run | < Thread Info
osRtxObject_t | ready | Ready List Object.
osRtxThread_t * | idle | Idle Thread.
osRtxThread_t * | delay_list | Delay List.
osRtxThread_t * | wait_list | Wait List (no Timeout)
osRtxThread_t * | terminate_list | Terminate Thread List.
thread | robin |

struct osRtxInfo_t.thread.run

Data Fields
osRtxThread_t * | curr | < Thread Run Info Current running Thread
osRtxThread_t * | next | Next Thread to Run.

struct osRtxInfo_t.thread.robin

Data Fields
osRtxThread_t * | thread | < Thread Round Robin Info Round Robin Thread
uint32_t | tick | Round Robin Time Tick.
uint32_t | timeout | Round Robin Timeout.

struct osRtxInfo_t.isr_queue

Data Fields
uint16_t | max | < ISR Post Processing Queue Maximum Items
uint16_t | cnt | Item Count.
uint16_t | in | Incoming Item Index.
uint16_t | out | Outgoing Item Index.
void ** | data | Queue Data.

struct osRtxInfo_t.mem

Data Fields
void * | stack | < Memory Pools (Variable Block Size) Stack Memory
void * | mp_data | Memory Pool Data Memory.
void * | mq_data | Message Queue Data Memory.
void * | common | Common Memory.

struct osRtxInfo_t.mpi

Data Fields
osRtxMpInfo_t * | stack | < Memory Pools (Fixed Block Size) Stack for Threads
osRtxMpInfo_t * | thread | Thread Control Blocks.
osRtxMpInfo_t * | timer | Timer Control Blocks.
osRtxMpInfo_t * | event_flags | Event Flags Control Blocks.
osRtxMpInfo_t * | mutex | Mutex Control Blocks.
osRtxMpInfo_t * | semaphore | Semaphore Control Blocks.
osRtxMpInfo_t * | memory_pool | Memory Pool Control Blocks.
osRtxMpInfo_t * | message_queue | Message Queue Control Blocks.

struct osRtxConfig_t.isr_queue

Data Fields
void ** | data | < ISR Post Processing Queue Queue Data
uint16_t | max | Maximum Items.
uint16_t | padding |

struct osRtxConfig_t.mem

Data Fields
void * | stack_addr | < Memory Pools (Variable Block Size) Stack Memory Address
uint32_t | stack_size | Stack Memory Size.
void * | mp_data_addr | Memory Pool Memory Address.
uint32_t | mp_data_size | Memory Pool Memory Size.
void * | mq_data_addr | Message Queue Data Memory Address.
uint32_t | mq_data_size | Message Queue Data Memory Size.
void * | common_addr | Common Memory Address.
uint32_t | common_size | Common Memory Size.

struct osRtxConfig_t.mpi

Data Fields
osRtxMpInfo_t * | stack | < Memory Pools (Fixed Block Size) Stack for Threads
osRtxMpInfo_t * | thread | Thread Control Blocks.
osRtxMpInfo_t * | timer | Timer Control Blocks.
osRtxMpInfo_t * | event_flags | Event Flags Control Blocks.
osRtxMpInfo_t * | mutex | Mutex Control Blocks.
osRtxMpInfo_t * | semaphore | Semaphore Control Blocks.
osRtxMpInfo_t * | memory_pool | Memory Pool Control Blocks.
osRtxMpInfo_t * | message_queue | Message Queue Control Blocks.

## Macro Definition Documentation

#define osRtxVersionAPI 20010003

API version (2.1.3)

#define osRtxVersionKernel 50040000

#define osRtxKernelId "RTX V5.4.0"

#define osRtxIdInvalid 0x00U

#define osRtxIdThread 0x01U

#define osRtxIdTimer 0x02U

#define osRtxIdEventFlags 0x03U

#define osRtxIdMutex 0x04U

#define osRtxIdSemaphore 0x05U

#define osRtxIdMemoryPool 0x06U

#define osRtxIdMessage 0x07U

#define osRtxIdMessageQueue 0x08U

#define osRtxFlagSystemObject 0x01U

#define osRtxFlagSystemMemory 0x02U

#define osRtxKernelInactive ((uint8_t)osKernelInactive)

#define osRtxKernelReady ((uint8_t)osKernelReady)

#define osRtxKernelRunning ((uint8_t)osKernelRunning)

#define osRtxKernelLocked ((uint8_t)osKernelLocked)

#define osRtxKernelSuspended ((uint8_t)osKernelSuspended)

#define osRtxThreadStateMask 0x0FU

#define osRtxThreadInactive ((uint8_t)osThreadInactive)

#define osRtxThreadReady ((uint8_t)osThreadReady)

#define osRtxThreadRunning ((uint8_t)osThreadRunning)

#define osRtxThreadBlocked ((uint8_t)osThreadBlocked)

#define osRtxThreadTerminated ((uint8_t)osThreadTerminated)

#define osRtxThreadWaitingDelay ((uint8_t)(osRtxThreadBlocked | 0x10U))

#define osRtxThreadWaitingJoin ((uint8_t)(osRtxThreadBlocked | 0x20U))

#define osRtxThreadWaitingThreadFlags ((uint8_t)(osRtxThreadBlocked | 0x30U))

#define osRtxThreadWaitingEventFlags ((uint8_t)(osRtxThreadBlocked | 0x40U))

#define osRtxThreadWaitingMutex ((uint8_t)(osRtxThreadBlocked | 0x50U))

#define osRtxThreadWaitingSemaphore ((uint8_t)(osRtxThreadBlocked | 0x60U))

#define osRtxThreadWaitingMemoryPool ((uint8_t)(osRtxThreadBlocked | 0x70U))

#define osRtxThreadWaitingMessageGet ((uint8_t)(osRtxThreadBlocked | 0x80U))

#define osRtxThreadWaitingMessagePut ((uint8_t)(osRtxThreadBlocked | 0x90U))

#define osRtxThreadFlagDefStack 0x10U

Default Stack flag

#define osRtxStackMagicWord 0xE25A2EA5U

Stack Magic Word (Stack Base)

#define osRtxStackFillPattern 0xCCCCCCCCU

#define osRtxTimerInactive 0x00U

Timer Inactive

#define osRtxTimerStopped 0x01U

#define osRtxTimerRunning 0x02U

#define osRtxTimerPeriodic ((uint8_t)osTimerPeriodic)

#define osRtxThreadFlagsLimit 31U

#define osRtxEventFlagsLimit 31U

#define osRtxMutexLockLimit 255U

#define osRtxSemaphoreTokenLimit 65535U

#define osRtxConfigPrivilegedMode (1UL<<0)

OS Configuration flags Threads in Privileged mode

#define osRtxConfigStackCheck (1UL<<1)

#define osRtxConfigStackWatermark (1UL<<2)

## Function Documentation

void SVC_Handler | ( | void |  | ) |

void PendSV_Handler | ( | void |  | ) |

void SysTick_Handler | ( | void |  | ) |

## Variable Documentation

osRtxInfo_t osRtxInfo

osRtxObjectMemUsage_t osRtxThreadMemUsage

osRtxObjectMemUsage_t osRtxTimerMemUsage

osRtxObjectMemUsage_t osRtxEventFlagsMemUsage

osRtxObjectMemUsage_t osRtxMutexMemUsage

osRtxObjectMemUsage_t osRtxSemaphoreMemUsage

osRtxObjectMemUsage_t osRtxMemoryPoolMemUsage

osRtxObjectMemUsage_t osRtxMessageQueueMemUsage

const osRtxConfig_t osRtxConfig