Answer:
In multi-programming, you use semaphore constructs to protect shared resources. Your program thread or process will block if you want to claim a semaphore when another thread or process has it claimed.
Generally you need to keep the code scope of the claimed semaphore (a.k.a. the critical section) as small as possible, and also, prevent claiming another semaphore within a given critical section.