lock variable initially 0
when a process wants to enter its critical region, it first test the lock if lock is 0 the process will set it to 1 and enters the critical region.
if the lock is already 1 the process will wait until it becomes 0 , thus 0 means that no process is in its critical region.
The result is showing just "process 1 waiting" not switching processes. what should i change or add in the code .