Lines Matching full:mutex
6 A :dfn:`mutex` is a kernel object that implements a traditional
7 reentrant mutex. A mutex allows multiple threads to safely share
18 Any number of mutexes can be defined (limited only by available RAM). Each mutex
21 A mutex has the following key properties:
23 * A **lock count** that indicates the number of times the mutex has been locked
24 by the thread that has locked it. A count of zero indicates that the mutex
27 * An **owning thread** that identifies the thread that has locked the mutex,
30 A mutex must be initialized before it can be used. This sets its lock count
34 to access it by **locking** the associated mutex. If the mutex is already locked
35 by another thread, the requesting thread may choose to wait for the mutex
38 After locking a mutex, the thread may safely use the associated resource
42 it must **unlock** the mutex to allow other threads to use the resource.
44 Any number of threads may wait on a locked mutex simultaneously.
45 When the mutex becomes unlocked it is then locked by the highest-priority
49 Mutex objects are *not* designed for use by ISRs.
54 A thread is permitted to lock a mutex it has already locked.
56 in its execution when the mutex may or may not already be locked.
58 A mutex that is repeatedly locked by a thread must be unlocked an equal number
59 of times before the mutex becomes fully unlocked so it can be claimed
65 The thread that has locked a mutex is eligible for :dfn:`priority inheritance`.
67 if a higher priority thread begins waiting on the mutex. This allows the owning
68 thread to complete its work and release the mutex more rapidly by executing
69 at the same priority as the waiting thread. Once the mutex has been unlocked,
71 that mutex.
78 The owning thread's base priority is saved in the mutex when it obtains the
79 lock. Each time a higher priority thread waits on a mutex, the kernel adjusts
82 base priority from the value saved in the mutex.
84 This works well for priority inheritance as long as only one locked mutex is
88 that a thread lock only a single mutex at a time when multiple mutexes are
94 Defining a Mutex
97 A mutex is defined using a variable of type :c:struct:`k_mutex`.
100 The following code defines and initializes a mutex.
108 Alternatively, a mutex can be defined and initialized at compile time
117 Locking a Mutex
120 A mutex is locked by calling :c:func:`k_mutex_lock`.
123 for the mutex to become available if it is already locked by another thread.
129 The following code waits up to 100 milliseconds for the mutex to become
130 available, and gives a warning if the mutex does not become available.
135 /* mutex successfully locked */
140 Unlocking a Mutex
143 A mutex is unlocked by calling :c:func:`k_mutex_unlock`.
146 and unlocks the mutex that was previously locked by the thread.
155 Use a mutex to provide exclusive access to a resource, such as a physical
181 User Mode Mutex API Reference