<p><pre><code> How does this algorithm achieves mutual exclusion, progress and bounded waiting if it does?
I realize this is not something simple. I actually have a video course for this which is in Hindi but I am not understanding the concept at all.
[code]
do
{
key=true;
while(key==true)
{
swap(&lock,&key);
}
critical section
lock=false;
Remainder Section
}while(true);
void swap(boolean *a, boolean *b)
{
boolean temp=*a;
*a=*b;
*b=temp;
}
[/code]
How do I prove if it satisfied mutual exclusion, progress and bounded waiting?</code></pre>
It is truly unfortunate that most languages lack a built-in swap instruction. Anyway, as written, your example looks like an infinite loop (Remainder Section would need to force an exit). What is the status of "lock" on entering the top of the loop? If it is "true" then this won't work (infinite loop in the while statement).