mirror of
https://github.com/espressif/esp-idf.git
synced 2026-01-15 10:15:32 +00:00
The existing spinlock mechanism possibly has an overlap of memory operations during multi core execution, as visible in CI testing. When running the example inter_cpu_critical_section, shared count increment stops at 299999 instead of reaching 300000, but this only happens randomly 1 out of 10 times. It is suspected that a memory operation happens simultaneously from both core, even though spinlock protection is in place. To handle this problem, a memory barrier (fence instruction) is added at critical places during spinlock acquire and release, to ensure that all memory operations upto that point are completed and synchronised before proceeding further.