# ARM Cortex-M mutex instructions

**URL:** <https://forums.freertos.org/t/arm-cortex-m-mutex-instructions/6226>\
**Category:** Kernel\
**Created:** [October 31, 2016, 10:02pm UTC](https://forums.freertos.org/t/arm-cortex-m-mutex-instructions/6226 "2016-10-31T22:02:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 31, 2016, 10:02pm UTC](https://forums.freertos.org/t/arm-cortex-m-mutex-instructions/6226/1 "2016-10-31T22:02:26Z")

</div>

**[nelsonpina](https://sourceforge.net/u/nelsonpina/)** wrote on [Monday, October 31, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/2b273560/#cec6):

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](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

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 31, 2016, 10:31pm UTC](https://forums.freertos.org/t/arm-cortex-m-mutex-instructions/6226/2 "2016-10-31T22:31:20Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Monday, October 31, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/2b273560/#7123):

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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 2, 2016, 11:26am UTC](https://forums.freertos.org/t/arm-cortex-m-mutex-instructions/6226/3 "2016-11-02T11:26:32Z")

</div>

**[nelsonpina](https://sourceforge.net/u/nelsonpina/)** wrote on [Wednesday, November 02, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/2b273560/#57e5):

Thanks Medwards!
