zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.61k stars 6.5k forks source link

Add static allocation of RTOS objects for CMSIS-RTOSv2 API port #75626

Open utsavm9 opened 2 months ago

utsavm9 commented 2 months ago

Introduction

When creating Zephyr RTOS objects like mutex, timers or message queues via CMSIS-RTOSv2 API, there are two options for the users to choose - dynamic allocation or RTOS implementation-specific static allocation. Dynamic allocation is what's currently supported by Zephyr portability layer with static allocation left unimplemented.

Problem description

It is a hassle to keep a track of how many RTOS objects a project might be using. With dynamic allocation, we need to declare this via configs like CONFIG_CMSIS_V2_MUTEX_MAX_COUNT. Either memory is getting wasted by allocating huge pools which are not fully used, or these configs need manual update as different libraries get added/removed to a project.

Proposed change

The above will not be a problem if Zephyr's CMSIS-RTOSv2 port supports static memory allocation. I plan on

Dependencies

This would not impact existing use of dynamic allocation for creating RTOS objects via CMSIS-RTOSv2.

Concerns and Unresolved Questions

Let me know of any concerns or ideas, otherwise I am creating a pull request implementing this proposal.

github-actions[bot] commented 2 months ago

Hi @utsavm9! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙