# Is Bounded Waiting satisfied for this 2 process Solution?

This is my new post linked with my previous post.

Is bounded waiting satisfied in the 2 Process Solution?

The answer in that post was very useful and cleared many concepts, but I just want to apply that answer for this example, that how BW works here .

Especially, I want to know this definition works for this example.

Define $k$-bounded waiting for a given mutual exclusion algorithm to mean that if $D_A^j \to D_B^l$ then $CS_A^{j} \to CS_B^{l+k}$.

Here, the Question comes

What can be said bout the Bounded Waiting of this 2 process solution"

<------- P1 ------->

While(True)
{
acquire(lock1)
acquire(lock2)
withdraw(from, amount)
deposit(to, amount)
release(lock2)
release(lock1)
}


<-------- P2 -------->

While(True)
{
acquire(lock1)
acquire(lock2)
withdraw(from, amount)
deposit(to, amount)
release(lock2)
release(lock1)
}

• Can you articulate a more specific question than "What can be said about..."? What specifically are you unsure/confused about? Have you tried applying the definition to that example, and what did you come up with and where specifically did you get stuck/confused? – D.W. Dec 14 '16 at 9:53

In the following, I treat the first two statements acquire(lock1) acquire(lock2) as "trying", the middle two statements withdraw(from, amount) deposit(to, amount) as the "critical section", and the last two statements release(lock2) release(lock1) as "exiting".
This algorithm does not satisfy the bounded waiting property. Consider the following execution: $P_1$ and $P_2$ simultaneously execute acquire(lock1) and $P_1$ wins. $P_1$ acquires lock2 successfully, enters the critical section, and then exit by releasing locks. Now, $P_1$ and $P_2$ contend on acquire(lock1) again and $P_1$ wins again .... In this way, $P_2$ is actually starved.
• @PavanKumarMunnam You are talking about a single individual detailed implementation. However, you should focus on the worst-case scenario. In addition, being woken up does not mean $P_2$ immediately holds the lock. It has to compete with $P_1$ which is also trying to acquire the same lock. The worst case here is to let $P_1$ always win. – hengxin Dec 15 '16 at 5:28