The Cortex-M4
processor implements a local exclusive monitor. For more information about
semaphores and the local exclusive monitor see the ARMv7M ARM Architecture Reference
Manual.
Instructions:
Exclusive instructions must be used in pairs:
So LDEX/STREX must be placed in loop, to repeat LDREX/modify/STREX if STREX fails.