Mutex: Difference between revisions

Content added Content deleted
(Created)
 
m (Race condition link)
Line 3: Line 3:
'''Mutex''' (''abbreviated'' '''Mut'''ually '''Ex'''clusive access) is a synchronization object, a variant of [[semaphore]] with ''k''=1. Mutex is said to be seized by a [[task]] decreasing ''k''. It is released when the task restores ''k''. Mutexes are typically used to protect a shared resource from concurrent access. A [[task]] seizes the mutex, then accesses the resource, and after that releases the mutex.
'''Mutex''' (''abbreviated'' '''Mut'''ually '''Ex'''clusive access) is a synchronization object, a variant of [[semaphore]] with ''k''=1. Mutex is said to be seized by a [[task]] decreasing ''k''. It is released when the task restores ''k''. Mutexes are typically used to protect a shared resource from concurrent access. A [[task]] seizes the mutex, then accesses the resource, and after that releases the mutex.


Mutex is a low-level synchronization primitive exposed to deadlocking. A deadlock can be constructed already with two tasks and two mutexes. Entering the deadlock is usually aggravated by a race condition state.
Mutex is a low-level synchronization primitive exposed to deadlocking. A deadlock can be constructed already with two tasks and two mutexes. Entering the deadlock is usually aggravated by a [[race condition]] state, which leads to sporadic hangups, very difficult to track down.


==Variants of mutexes==
==Variants of mutexes==