algorithmconcurrencydeadlockconcurrent-programmingmutual-exclusion

Does this uphold Mutual Exclusion: Concurrent programming?


1/ Does the algorithm uphold Mutual Exclusion?

2/ Is the algorithm free from deadlock and is starvation possible?

I can't seem to get my head around deadlock. I do believe there is no mutual exclusion as any client can enter the critical section?

Thanks


Solution

  • This is an algorithm where clients request a "lock" that is granted by a server.

    1. This indeed is a mutual exclusion algorithm. Assume to the contrary that two client i and j are between C2 and C3. W.l.o.g, say that i was the first one to enter the critical section.

      1. When i did so, necessarily respond = i had to be true at C1. This had to happen at the server's Q2.

      2. Looking at the server's code, it can't reach Q2 again until Q3 fails, namely until respond == 0. Looking at the client's code, this could only happen when i left the critical section at C3.

      3. This contradicts j being simultaneously in the critical section - Q2 could only be reached again when i left the critical section, so, before that, it is impossible that j passed C1.

    2. The algorithm is not free from starvation. Client j could unlimitedly be untimely bypassed by some client i. The algorithm is free from deadlock: there is only a single critical section, and if any thread entering it will eventually exit it, then it will be eventually available to another thread (albeit possibly the same one).