Page 1 of 1

Mutex without FreeRTOS

Posted: Sun Apr 08, 2018 10:12 am
by michprev
Hello,
what is the correct way to implement simple mutex to share date between Core 0 (FreeRTOS) and Core 1 (without FreeRTOS)? There is a simple example for ARM: http://infocenter.arm.com/help/index.js ... 03s02.html.

Re: Mutex without FreeRTOS

Posted: Sun Apr 08, 2018 2:07 pm
by ESP_igrr
You can build some form of mutual exclusion on top of the atomic compare-and-set instruction.

Here's the basic C wrapper for it: https://github.com/espressif/esp-idf/bl ... #L273-L290

Xtensa port of FreeRTOS has its spinlocks (portMUX_TYPE) built on top of it: https://github.com/espressif/esp-idf/bl ... ort.c#L302 (the link is to an older version, because the most recent one in master branch is a bit more complicated due to external RAM support).

Re: Mutex without FreeRTOS

Posted: Thu Apr 12, 2018 10:26 pm
by michprev
Is there any option for dual-core mutex? E. g. what happens when both cores access the same peripheral register / memory segment?

Re: Mutex without FreeRTOS

Posted: Fri Apr 13, 2018 2:58 am
by ESP_Sprite
That is what the spinlock is for. On unicore systems, just disabling the interrupts is enough, but on multicore you need spinlocks.