• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Can anyone help me on my summer session hw (CS related)

sdaccord01

Senior member
Hi, I have homework due this wednesday and I can't figure this one problem out in the book. It is Operating Systems 4th Edition by William Stallings and the problem is on page 257, 5.5. It has to do with processes and I can't figure out why the algorithm doesn't work. Any help is much appreciated, thanks. They said that the mutual exclusion problem was proposed in HYMA66.

Ken
 
Oh yeah, here's the problem:

boolean blocked [2];
int turn;
void P (int id)
{
while (true)
{
blocked[id] = true;
while (turn != id)
{
while (blocked[1-id])
{
turn = id;
}
}
/* critical section */
blocked[id] = false;
/* remainder */
}
}
void main( )
{
blocked[0] = false;
blocked[1] = false;
turn = 0;
parbegin (P(0), P(1));
}


Mutual Exclusion Rules:
-The number of processes in the critical section is never more than 1
-No process outside a critical section may block others
-No process may wait forever to enter critical section
-No assumption about speeds or number of CPU?s

I'm supposed to find a counterexample to show that this solution is incorrect for mutual exclusion. Basically I need to find out how it violates one of the mutual exclusion rules.
 
Back
Top