-
From my embedded systems experience, when I use an RTOS I configure the OS buffer size and can divvy that up however I wish. For example I create 3 threads of various sizes say 1KB, 2 KB, 3KB (6KB of threads in total) and as long as the total is below the OS buffer size all is well. This is also the approach the CMSIS RTOSv2 wrapper takes when creating a thread where the However, Zephyr's implementation decides not to follow so nor documents the deviation from this... Zephyr's implementation decides that dynamic allocation will not follow CMSIS's documentation and instead allocates a stack array of Looking through the commit history of the thread.c file for CMSIS RTOS v2, the only hint I can find as to why is a message from 2019. Why not allocate a CMSIS heap to use for thread creation, like other RTOSs, and divvy up based on the requested size instead of silently assigning a static size? For alignment purposes, could just round the programmer provided size up to the nearest valid aligned size when threads are created with dynamic memory. Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
@htcrane The interpretation of the following may be ambiguous:
When stack_mem is NULL, it is mentioned that the stack is provided by the underlying RTOS. This implies that the stack_size parameter is irrelevant in this case, as the stack size is determined by the RTOS configuration, not by stack_size. However, if both defaults are combined—stack_mem is NULL and stack_size is 0—it means that the stack size and allocation are based on the underlying RTOS kernel. Anyway, Zephyr RTOS is a good platform to adopt, and the benefits of CMSIS RTOS are minimal compared to the extensive ecosystem provided by Zephyr. 🚀 |
Beta Was this translation helpful? Give feedback.
-
I do not believe that ignoring input parameters will be a good practice, nor what is meant...
The purpose of CMSIS RTOS is to provide a wrapper so applications can be RTOS independent. I will be opening a PR with updates to Zephyr's implementation to follow expected behavior of CMSIS RTOS. Also, I will be updating some of the ISR restrictions as it appears the Zephyr kernel has better support within ISRs at this time. --
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your detailed and insightful response. Your explanation about the stack_size parameter and its handling across different RTOS implementations is very clear. I appreciate the points you made about FreeRTOS, ESP, Mbed OS, and Zephyr.
|
Beta Was this translation helpful? Give feedback.
FYI 👀, @htcrane PR #75804