Skip to content

Commit 0ed3b02

Browse files
author
Amanda Butler
authored
Merge pull request #769 from aashishc1988/mutex_doc
Mutex doc
2 parents c5afb82 + bbc5297 commit 0ed3b02

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/api/rtos/Mutex.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@
44

55
A Mutex is used to synchronize the execution of threads, for example to protect the access to a shared resource.
66

7-
<span class="notes"> **Note:** The `Mutex` methods cannot be called from interrupt service routines (ISR). In the current version of Mbed OS, if you attempt to use a mutex from within an ISR, nothing happens; attempts to lock a mutex succeed immediately, regardless of whether the lock is actually free. In other words, if you acquire a mutex lock in an ISR, you can break the thread safety mechanisms and introduce race-conditions into an otherwise safe piece of code. Future versions of Mbed OS will provide warnings and ultimately prevent this from happening. </span>
7+
The `Mutex` methods cannot be called from interrupt service routines (ISR). In the current version of Mbed OS, if you attempt to use a mutex from within an ISR, it will treat that as a fatal system error, and you will see an error like this:
8+
9+
```C
10+
++ MbedOS Error Info ++
11+
Error Status: 0x80020115 Code: 277 Module: 2
12+
Error Message: Mutex lock failed
13+
Location: 0x80026B3
14+
Error Value: 0xFFFFFFFA
15+
Current Thread: Id: 0x20004F54 Entry: 0x8002ABF StackSize: 0x1000 StackMem: 0x20004F98 SP: 0x2004FEF8
16+
For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80020115
17+
-- MbedOS Error Info --
18+
```
19+
20+
<span class="notes"> **Note:** If synchronization is required in ISR, consider using semaphores. </span>
821

922
<span class="images">![](https://s3-us-west-2.amazonaws.com/mbed-os-docs-images/Mutex.png)</span>
1023

0 commit comments

Comments
 (0)