Operating Systems
how do semaphores support mutual exclusion ?
Answer:-
First of all semaphore is variable used to solve critical section problem.
There are two operations in semaphores. one is wait() and another one is signal()
implementation of wait:-
wait(Semaphore s)
{
while(s==0); //wait untill s==0//
s = s-1 //decrements semaphore value
}
implementation of signal:-
signal(Semaphore s)
{
s = s+1;
}
support for mutual exclusion through semaphore:-
first of all semaphore initialized to 1 and p1 and p2 are two processes
step1:- s=1 p1,p2 //not in critical section//
step2:- if p1 enters into critical section.
it will call wait() operation
then s =0
step3:- another process p2 can not enter critical section until p1 calls signal opeartion //supports mutual exclusion//
step4:- p1 completes its operation then calls signal() function
step:-now s=1 then p2 can enter critical section.
process will implement following procedure for mutual exclusion:-
while(True)
{
//non critical section//
wait(s);
//critical section//
signal(s);
}
We discussed the use of spin-locks and semaphores for achieving mutual exclusion. Semaphores are designed to avoid busy waiting and provide fairness. (a) Is it always desirable to use semaphores rather than spin-locks? To answer, address the overhead incurred in each approach. (b) Discuss the situations in which each one is preferred.
Operating system Why we need mutual exclusion, and how it is implemented?
Why do some operating systems support specific types of file structures and why do some operating systems don’t?
P(sem) and V(sem) operations on semaphores are executed atomically. What will be the outcome of not executing P(sem) atomically? Specify where the interrupt occurs. Give one execution sequence of concurrent processes that will show a specific Condition (Mutual Exclusion or Starvation or Progress Condition) violated. Be detailed in your explanation.
Define syncronization delay in distributed mutual exclusion and explain why it is a relevant element in the performance evaluation of distributed mutual exclusion algorithms.
Many mutual exclusion algorithms are verified using computer programs. Briefly outline how these programs manage to verify that a certain algorithm is correct.
In all computer system, there is a component of the system which provides fundamental mutual exclusion protection. what is this component, why does it provide mutual exclusion and why is it insufficient to protect against asynchrony?
Why might it be considered bad practice to use a spinlock to enforce mutual exclusion on a computer with one core, but be acceptable to do so on a computer with multiple cores?
To Implement Mutual Exclusion some Parameters must be taken into consideration. Explain them, Also State the Attempts to Implement Mutual Exclusion.
Why is it that using a mutual exclusion does NOT ensure that a system avoids deadlock?