Mutexes are typically used to serialise access to a section of re-entrant code that cannot be executed concurrently by more than one thread. A mutex object only allows one thread into a controlled section, forcing other threads which attempt to gain access to that section to wait until the first thread has exited from that section.
A semaphore restricts the number of simultaneous users of a shared resource up to a maximum number. Threads can request access to the resource (decrementing the semaphore), and can signal that they have finished using the resource (incrementing the semaphore).
Q: What is the difference between Mutex and binary semaphore?
A: The differences are:
1) Mutex can be used only for mutual exclusion, while binary can be used of mutual exclusion as well as synchronisation.
2) Mutex can be given only by the task that took it.
3) Mutex cannot be given from an ISR.
4) Mutual-exclusion semaphores can be taken recursively. This means that the semaphore can be taken more than once by the task that holds it before finally being released.
5) Mutex provides a options for making the task that took it as DELETE_SAFE. This means, that the task cannot be deleted when it holds mutex.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment