Initial condition : S0=1, S1=0, S2=0,
so process P1 and P2 have to wait and only P0 can execute first.
After completing one iteration of the while loop, 0 is printed once.
Now the semaphore variables are – S0=0, S1=1, S2=1
In the minimalist case – P1 and P2 both will be incrementing S0 in one go, so after both P1 and P2 complete execution,
S0=1, S1=0, S2=0
now again P0 will be executed and print 0.
After that it will set S0=0.
So in the worst case S0 will be printed twice.
S0 willbe printed atleast twice.