Final answer:
Semaphores are synchronization primitives with an integer value. They can act as locks when initialized to 1 and can handle multiple resources when set above 1. Semaphore values don't go negative, and sem_post() does not block.
Step-by-step explanation:
A semaphore is indeed a useful synchronization primitive in concurrent programming. Here are the clarifications for the statements provided:
- a. True. Each semaphore has an integer value which typically represents the number of resources available.
- b. True. If a semaphore is initialized to 1, it can act as a mutex lock, ensuring exclusive access to a resource.
- c. True. Semaphores can be initialized with values higher than 1, enabling control over access to multiple resources of the same type.
- d. True. Semaphore values can indirectly be negative if more processes are waiting than the number of resources available, though the actual counter does not go below zero.
- e. False. Calling sem_post() increments the semaphore's value and never blocks; it might wake up another thread if it is waiting.
It is important to understand how semaphores function as they play a critical role in avoiding race conditions and ensuring proper synchronization in multi-threaded applications.