Put mutex in shared memory (FreeRTOS on two processors)


i am working on an arm cortex a9 dual core processor. on each core runs a FreeRTOS instance (they dont know anything about each other). The cores have on-chip-memory that they share. is it possible to place a mutex in this shared memory and let FreeRTOS on core 1 and FreeRTOS on core 2 access it to synchronize threads across cores?

many thanks in advance

No, unfortunately that is not possible. Steam and message buffers are the only primitive designed for core to core communication.

can you also say why its not working. what would go wrong?

and how are those Steam and message buffers protected against simultaneous accesses? can a thread wait until something appears in the message buffer?

thanks for your reply

See this approach Simple Multicore Core to Core Communication Using FreeRTOS Message Buffers - FreeRTOS
to get inspired :slight_smile:

already read this article thanks… was more interested why one cannot use the mutexes for core to core communication.

do you know anything more? can you answer the questions above?

The key difference between a StreamBuffer and a Queue/Semaphore/Mutex is that the StreamBuffer is only allowed to have a SINGLE write and a SINGLE reader (at a given time), so only one task can be blocked on it. This simplifies the logic such that it was possible to add a hook to allow cross-core/cross-kernel (AMP) notifications to StreamBuffers which would be very hard to add to Queues, since it would need to deal with having to figure out which kernel a give task on the waiting list belongs to.

Since there is no underlying OS/kernel as on Linux managing a globally shared mutex data structure (in fact it’s 1 kernel hosted sync object ) there is just no way to do so with 2 completely separated/independent FreeRTOS executables.
You’ve to use an interrupt based / message passing approach with this scenario.

1 Like

thank you so much all