My team and I are currently completely redesigning our serially executed system in order to use FreeRTOS, which introduced a lot of concurrency and successivly unforseen related problems.
To give one (the biggest problem) example:
We plan to use a Cache-Manager-Task, which manages all concurrent accesses to flash memory.
Writing to Cache is no problem, since we send message containg a pointer to dynamic memory. Ownership to this memory will be granted to the Cache, which will free the dynamic memory once it is copied to flash. Thus, any task writing to cache (by sending a message to the Chache’s queue, can continue to execute it’s code.
Reading from cache is a BIG problem, though:
The task wishing to read sends an appropriate message to the task, together with a pointer into which the Cashe should read the flash into.
Unfortunately, the task must now wait, until the Cache sends a message, that the read as been performed. This introduces a lot of problems:
1. Our code becomes fragmented, if several reads must be performed, mostly because, Reads are limited to flash pages (256 byte). We can no longer loop over the flash.
2. Since we must wait for the cache, other events (messages) may have been put into our task’s queue, before the result message from the cache arrives, introducing very nasty concurrency.
I have no idea about what to do aside from writing very complex code, which frustrates me and my team a lot.
Is there any possibility to halt my task and somehow continue at the exact place from where the read request was sended, thus bypassing the message queue?