richard_damon wrote on Sunday, November 27, 2016:
On processors without a MMU (which is likely most of them used with FreeRTOS, and how it started), things are pretty simple. Everyone runs in the same memory space and everyone sort of trusts everyone as there isn’t much to do about it. Task Stacks, and the various control blocks can either be created on the ‘Heap’ (either the standard C heap from malloc/free (with a wrapping layer to keep them thread safe) or more specialize routines to hand out memory from a specialized heap, or with other calls, you can create the needed structures from statically allocated memory.
Queue copy the data given into the memory allocated to the queue on a send, and that data is copied to the receiving task on a get. That data might be a pointer to memory that is just shared. Memory also can just be shared, with maybe a semaphore or mutex guarding it from incorrect multiple access.
With a MMU, things can get a bit more complicated, FreeRTOS and privileged tasks work just the same as above, but a task can also be made unpriviledge, and then the memory it can access is limited by the MMU (it might just be write access that is limited for normal memory, I haven’t used it). The task by default with be given Read/Write access to the reagon of memory allocated to its stack, and it can be given read/write access to a couple of other blocks of memory for shared memory access. I don’t think it uses the MMU to perform any address translation.
Note, this is a much simpler model than something like the Linux kernal, In particular, there is no dealing with ‘virtual addresses’, the MMU is generating protection rings, not remapping memory. Tus there is also no concept of swap space or virtual memory.