What are mutexes?

Embedded C interview Questions

What are mutexes?

Answer

A mutual exclusion object that allows multiple threads to synchronizes access to a shared resource. A mutex has two states: locked and unlocked. Once a thread has locked a mutex, other threads attempting to lock it will block. When the locking thread unlocks (releases) the mutex, one of the blocked threads will acquire (lock) it and proceed. 

If multiple threads or tasks are blocked on a locked mutex object, the one to take it and proceed when it becomes available is determined by some type of scheduling algorithm. For example, in a priority-based system, the highest priority blocked task will acquire the mutex and proceed. Another common set-up is put blocked tasks on a first-in-first-out queue.

No comments:

Post a comment