It wont work on any system actually.

Suppose a case in which lock = 0 initially.
And two threads are trying to execute the Critical Section.

Thread 1

just passed the if branch and is about to execute
the statement lock = 1;
just before that context switch happened.

Thread 2 will also enter into the critical section. And the result would be
unpredictable.


On Fri, Dec 7, 2012 at 4:23 AM, zerobyzero <[email protected]>wrote:

> if (lock)wait
> else
> lock=1
> CS
> lock=0
> a. No issues
> b. works only for uniprocessor systems
> c. data insufficient
> d. won’t work on any system
>
> --
>
>
>

-- 


Reply via email to