I was looking at process synchronization and came across test-and-set instruction
boolean testAndSet (boolean *target)
{
boolean rv = *target;
*target = true;
return rv;
}
main()
{
do
{
while( testAndSet( &lock ));
//critical section
lock = false;
//remainder section
}while(true);
}
This executes atomically (i.e. whenever a function call to testAndSet occurs no interrupt is handled till the function returns).
Now I understand how this eliminates mutual exclusion (since the waiting process gets stuck at the while loop if another process is executing it's critical section). But how does it satisfy Progress condition, and more importantly, how does it not satisfy bounded-buffer condition? Any help would be appreciated..