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.89k stars 6.63k forks source link

Reference Counting for memory-slabs #71175

Open stubb0rnCoder opened 7 months ago

stubb0rnCoder commented 7 months ago

When working e.g. with sensor data one may want to not pass a full sample struct around threads but rather a pointer to it. This in itself works fine with the memory-slab API. But once you start sending a sample to multiple threads e.g. a data logger and a sensor fusion module you either need to duplicate the data, which is a waste if none of the modules writes to the sample or add application logic to handle reference counting to only free the sample once all threads are done with it.

Adding a (atomic) reference counting to the memory-slab directly or replicate the module as a "reference_counted_memory_slab" would make the application code much more simple and avoid user errors.

github-actions[bot] commented 7 months ago

Hi @stubb0rnCoder! 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. 🤖💙