Hi , no the above code is right . this is because both process will use same code . I will explain you LOCK is a synchronisation variable . Let us see how . you will have LOCK=0 as initial value to get into critical section. Suppose if i have 2 process p1 p2 . And if anyone of the process P1 come then it , it will find lock value as 0 ryt ? Now while statement (0!=0) . false right . so it will go out of while loop and enter into critical section by making LOCK variable =1 . Now suppose this time if p2 come , it will grab lock varaible and check (lock!=0) -->(1!=0) ;which is true , so it will loop in while loop only (see ; after whileloop ). Hence you can get this would be exceution if any 1 process come first and then another one (while p1 is executing ) Now imagine a scenario when both process come together and grab a lock varaible (inital lock value is 0 ) . both will compare (0!=0) which is wrong so both of them simulatenously will enter critical section . And the thing that here Lock is used as one of door to critical section . Its not a critical section !