Assignment 3(problem 1)

31 views
Skip to first unread message

Rahul Shah

unread,
Mar 10, 2012, 1:16:54 PM3/10/12
to asu-cse-430
Is the whole shift function atomic or only the *A=*B part is atomic?

I think the whole function should be atomic because if not, suppose 2
process come at the same time.
Initially we consider *A=1;


//Considering *B as key for each process and *A as lock
1. P1 executes *B=*A; //key of P1 is set
2. P2 executes *B=*A; //key of P2 is set
3. P1 executes * A=0;// the Lock variable is 0
4. P2 executes *A=0; // the Lock variable is 0
5. Now if P1 check its key , it will enter into the critical section
6. P2 also check its key and find it set and enters into the critical
section //Mutual exclusion is violated

Instead if the whole SHIFT is atomic we wont have this problem

Partha Dasgupta

unread,
Mar 10, 2012, 4:09:27 PM3/10/12
to asu-c...@googlegroups.com
The whole shift function has to be atomic, for this to work -- both assignments are atomic (together).


--
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,
Mar 10, 2012, 6:50:39 PM3/10/12
to asu-cse-430
ok cool. That clears my doubt.
Reply all
Reply to author
Forward
0 new messages