Currently I am developing an embedded system, running multiple tasks within an RTOS on a heavily constrained (mainly memory-wise) system.
My team-lead advised the use of dynamic memory allocation. However, safety-critical standards like MISRA C advise against it.
So what are the sensible alternatives? Creating shared memory and handling it with mutexes / gates? Currently I am dynamically allocating memory and passing pointers to it between tasks, but I would greatly appreciate some insight on how to improve this design.
Some more info: The embedded system's goal is to a central communication module, communicating with several outside systems. These outside systems want information from the different tasks on the embedded system, and vice versa.
To accomplish this, all tasks must communicate with that communication module. This is currently done by dynamically allocating storage for that message, and passing the pointers between the tasks. The receiving task then frees the allocated memory. The choice for dynamic allocation was made because most tasks will not communicate very much, while our hardware platform is very memory-constrained.