Mutex without FreeRTOS

michprev
Posts: 92
Joined: Fri Aug 04, 2017 8:57 pm

Mutex without FreeRTOS

Postby michprev » Sun Apr 08, 2018 10:12 am

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.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Mutex without FreeRTOS

Postby ESP_igrr » Sun Apr 08, 2018 2:07 pm

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).

michprev
Posts: 92
Joined: Fri Aug 04, 2017 8:57 pm

Re: Mutex without FreeRTOS

Postby michprev » Thu Apr 12, 2018 10:26 pm

Is there any option for dual-core mutex? E. g. what happens when both cores access the same peripheral register / memory segment?

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: Mutex without FreeRTOS

Postby ESP_Sprite » Fri Apr 13, 2018 2:58 am

That is what the spinlock is for. On unicore systems, just disabling the interrupts is enough, but on multicore you need spinlocks.

Who is online

Users browsing this forum: No registered users and 142 guests