Binary semaphore S1=1 and S2=0
int x=10
| p0(){ p(s1) x=x+1 v(s2)} | --------------- | p1(){ p(s2) x=x+1 v(s1)} |
|---|
what will be the value of x after execution of p0 and p1?
The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:
void enter_CS(X)
{
while(test-and-set(X));
}
void leave_CS(X)
{
X = 0;
}
In the above solution, X is a memory location associated with the and is initialized to
. The above construct used by process p1 and p2. So above construct leads to deadlock?