High performance lock ? MutexGet MutexPut

Hello there! 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, #1n"           "    ldrexb   r2, [r0]n"           "    cmp      r2, #0n"           "    it       eqn"           "    strexbeq r2, r1, [r0]n"           "    mov      r0, r2n"           "    bx       lrn"           : "=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).     //     return(ulRet); } void WidgetMutexPut(unsigned char *pcMutex) {     //     // Release the mutex.     //     *pcMutex = 0; } Kind regards, Engin

High performance lock ? MutexGet MutexPut

Most semi complex architectures have instructions that can be used to implement mutexes, and indeed you could optimise individual ports this way.  The mutex code as it stands is in the common code and not in the portable layer, so it would require some major changes and a support nightmare.  Also, the mutex structures contain all the event control information, so tasks can block and be unblocked as semaphores are taken and given – all in strict priority order. Regards.

High performance lock ? MutexGet MutexPut

Hmm, so FreeRTOS is currently designed in a way that it cannot itself take advantage of this. i.e. it has [Enter|Exit]CriticalSection in portable layer and uses that as locks. Besides it wouldn’t support priority levels. Even though it is not appropriate for FreeRTOS as of today, is it suitable for simple usage in user programs ? i.e. it wouldn’t break anything and it would function as expected, right ? Kind regards, Engin