For Cortex-M3 port, I wonder if the mutex implementation in the grlib will make any use. Because it performs a lock without masking out the interrupts and could perform better ?
What do you think ?
Below is the code for MutexGet and MutexPut for your convenience (taken from widget.c of grlib of Luminary);
unsigned long __attribute__((naked))
WidgetMutexGet(unsigned char *pcMutex)
unsigned long ulRet;
// Acquire the mutex if possible.
__asm(" mov r1, #1\n"
" ldrexb r2, [r0]\n"
" cmp r2, #0\n"
" it eq\n"
" strexbeq r2, r1, [r0]\n"
" mov r0, r2\n"
" bx lr\n"
: "=r" (ulRet));
// The return is handled in the inline assembly, but the compiler will
// still complain if there is not an explicit return here (despite the fact
// that this does not result in any code being produced because of the
// naked attribute).
WidgetMutexPut(unsigned char *pcMutex)
// Release the mutex.
*pcMutex = 0;