Midterm Question 2

77 views
Skip to first unread message

Rahul Shah

unread,
Apr 28, 2012, 8:03:58 PM4/28/12
to asu-cse-430
Professor,

process i:

flag[i]=true;
turn=j;
while((flag[j] || flag[k]) && turn != i) do no op;

CS

flag[i] = false;


This was the question and to find out whether the algorithm satisfies
all 3 condition

Mutual exclusion is violated.

I have a doubt in Progress

Suppose a scenario

Initially
1. Process i comes flag[i]= true; turn = j;
2. Checks the while condition which is false because flag[j] and
flag[k] = false
3. Process i completes flag[i] = false
4. Process j arrives now flag[j]=true, turn =k
5. Checks the while condition which is false because flag[i] and
flag[k] = false
6. Process j starts executing but have not finished.
7. Process k arrives in the middle of the execution of process j
8. Process k: flag[k] = true and turn = i
9. Check the while condition but cannot run because flag[j]=true and
turn!=k...Process k busy waits
10. Process i arrives again before process j is done.
11. Process i: flag[i] = true and turn = j
12. Check the while condition but cannot run because flag[j]=true and
flag[k]=true and turn!=i...Process i busy waits
13. Now is process j completes and sets the flag[j] = false. none of
the process i or k can go ahead until process j arrives again makes
turn = k

So is this violation of progress because process i and k wants to
enter but cannot even though the CS is not used by any process?

Partha Dasgupta

unread,
Apr 29, 2012, 4:19:17 PM4/29/12
to asu-c...@googlegroups.com
>>  Mutual exclusion is violated. 

Once mutual exclusion is violated, then the rest become meaningless. If a calculator produces an answer other than 4, for 2+2 then whether is consistently produces 5 or 7 or fluctuates is all irrelevant.


--
You received this message because you are subscribed to the Google Groups "asu-cse-430" group.
To post to this group, send email to asu-c...@googlegroups.com.
To unsubscribe from this group, send email to asu-cse-430...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/asu-cse-430?hl=en.




--
Partha Dasgupta,
School of Computing Informatics, Arizona State University
EMail: par...@asu.edu
http://cactus.eas.asu.edu/partha

Rahul Shah

unread,
Apr 29, 2012, 11:30:07 PM4/29/12
to asu-cse-430
ok. :)
Reply all
Reply to author
Forward
0 new messages