Reputation: 762
We have three threads or more, can we use only two semaphores (binary or counting semaphores)? An idea that popped into my mind is playing with the number of sem_post-s and sem_wait-s. Any ideas, strategies are welcomed.
Upvotes: 0
Views: 388
Reputation: 67829
A semaphore is used to protect a shared resource. You need as many semaphores as shared resources, this is not linked to how many threads access these resources.
Upvotes: 2