Search code examples
deadlocksemaphorecritical-sectionmutual-exclusion

Critical section with sephamores


  1. Take this pseudo code,

    Semaphore S <- 0 
    non-critical section 
    wait(S)
    critical section 
    signal(S)
    

Does this solution to the critical section problem support mutual exclusion only?

I know that there is no freedom from deadlock since the critical section is never reached, however would that also mean that it does not support mutual exclusion.


Solution

  • Mutual Exclusion means that only 1 thread(or process) can enter the Critical Section. So by definition the code does not violate mutual exclusion.

    The important thing to note here is that all threads, would be in busy-waiting state, and there is no progress at all, but actually there is no deadlock, because one of the 4 must occur conditions for deadlock is CIRCULAR WAIT. But its not that threads are waiting for each other in this case.