10 - Mutual Exclusion Flashcards
What is mutual exclusion?
The problem of granting some exclusive privilege of a recourse to a process through the exchange of messages.
What are the requirements for a mutual exclusion solution?
- Safety: exclusive access
- liveness: no deadlock or starvation
- fairness: requests granted in some time order
What are the three classes of mutex algorithms?
- election based
- token based
- permission based
What class of mutex algorithm is Lamport’s?
Permission based
What type of timestamps does lamport’s mutex algorithm use?
Every message carries a scalar logical timestamp
What is the major assumption for lamports mutex algorithm?
Channels are FIFO
In mutex algorithms, what is the abreviation CS?
Critical section: The data area one tries to access using mutex.
What two requirements need to be met in order for process P to own a mutex?
- It has received a reply from every process
- its own request is at the head of its own request queue
Decribe the pseudo code for lamports mutex alg.
# Requesting CS in Pi: broadcast(REQUEST,ts,i) to all processes Receiving request,ts,j: send(REPLY, ts') to Pj enter (ts,j) into the request queue #Releasing the mutex of Pi: send(RELEASE,i) to all processes #Receiving a RELASE,j: remove (ts,j) from the request queue
Explain Lompart’s mutex message complexity.
It requires (n-1) REQUESTS, REPLIES and RELEASES. So complexity of 3(n-1)
What improvement does Ricart’s and Agrawala’s algorithm propose? and on what algorithm?
Improvement on lamport’s algorithm:
If Pi receives a REQUEST for CS of PJ that is lower priority than Pi’s own request to access Pj, then it will wait with sending a REPLY untill Pi has released it.
It allows any process to access a CS as often as it likes. (capped to complexity: fi. if all other processes also request access)
It is implied here that because Pi’s request is of higher priority, it will be granted access earlier. And that by REPLYing only after mutex is released, it acts as a release of sorts.
What is the complexity of Ricart-Agrawala’s mutex algorithm?
(n-1) Requests and (n-1) Replies = 2(n-1)
What class of mutex algrotihm is Ricart-Agrawala’s?
Permission based
What class of mutex algorithm is Maekawa’s?
Permission based.
Explain the main idea of Maekawa’s mutex algorithm.
every process has a request set of processes to which it sends its REQUESTs and from whom it needs REPLYs (better load distribution)
What are the Requirements and Desirable features of the request sets in Maekawa’s mutex algorithm?
Requirement:
* any two request sets have a non-empty intersection
Desirable features:
* every process is in its own request set
* all request sets have the same size
* every process is contained in the same number of request sets
In Maekawa’s mutex algorithm, what is the mininum size of the request set?
in the order of sqrt( N )
Explain what a deadlock is, and how it can occur.
A deadlock is an event in the system where multiple processes are actively waiting for eachothers response, whilst no responses can be generated. This can for instance occur in asynchronous systems if mutliple requests happen simultaneously.
How does Maekawa’s mutex algorithm handle deadlocks (incl. signals)?
Whenever process Pi has GRANTED access to Pj’s request of k, but later receives an other request for k from a different process (with higher priority), it will retract its original permission to j with an INQUIRE, which is confirmed by j with a RELINQUISH message.
However, if Pi receives a request for k that has lower priority (and it already granted k to pj), then it sends a POSTPONED