Hi. I want to use static memory for message queue in RTX5. What is the cb_size (size of provided memory for control block ) in osMessageQueueAttr_t. how to calculate proper size for it?
User can provide memory for Message Queue control block.
This memory needs to be aligned to words and big enough to hold the control block.
"cb_mem" should be filled with the pointer to that memory and "cb_size" with the size.
osRtxMessageQueueCbSize definition can be used to determine the size of required memory.
Tanks for your answer. The size of control block of a message queue can be calculated using os_MessageQueueCbSize.
I have a problem, Why in RTX5 the macro osMailQDef (used in former RTX) allocate a memory pool with size of the message type multiplied by count and also a message with that size. I mean that the osMailQDef allocate 2 time the size needed for a mail queue. In the RTX source cmsis_os.h the definition is:
static uint32_t os_mail_mp_data_##name[os_MemoryPoolMemSize ((queue_sz),sizeof(type))/4] static uint32_t os_mail_mq_data_##name[os_MessageQueueMemSize((queue_sz),sizeof(type))/4]
RTX5 implements the new CMSIS RTOS API V2 where Mail Queue has been deprecated and replaced with enhanced Message Queue.
RTX5 however provides also a compatibility layer for API V1 when selected. This layer also defines the legacy macros including osMailQDef.
Mail is implemented using a Memory Pool which stores mail data and a Message Queue which stores only pointers to mail data. Therefore both mentioned variables are needed.
But you are right in regards to message queue data size which needs to hold only pointers and should be decreased as shown below. Will be fixed in the next release (already accessible in development version on github).
static uint32_t os_mail_mp_data_##name[osRtxMemoryPoolMemSize ((queue_sz),sizeof(type) )/4]; static uint32_t os_mail_mq_data_##name[osRtxMessageQueueMemSize((queue_sz),sizeof(void*))/4];