Semaphore using 2 keys and 3 keys

In reply to Shruti Kamble:

I assume you also changed sema.put(2) to (3).

If there are initially 4 keys, and each process needs 3 available keys, then only one process can run at a time.

Also see Semaphore understanding | Verification Academy