ARM Cortex-M mutex instructions

nelsonpina wrote on Monday, October 31, 2016:

Hey guys,

let’s say I need to use a mutex in my driver layer and I don’t want to use FreeRTOS calls that deep in my code (to keep the drivers independent from FreeRTOS).

Is there any side effect of using the ARM Cortex-M mutex instructions when using FreeRTOS:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHEJCHB.html

I do use the FreeRTOS semaphores and mutex in my application layers, but I want to avoid using them at driver levels.

Thanks a lot!

cheers,
n

edwards3 wrote on Monday, October 31, 2016:

FreeRTOS mutexes are heavy as they use the queue code so can have any number of tasks blocked on giving or taking them. They do give you blocking ability and priority inheritance though. Do not use a spin lock on a Cortex instruction because lower priority tasks will be starved and you will get deadlock if a starved task has the lock.

nelsonpina wrote on Wednesday, November 02, 2016:

Thanks Medwards!