What is the difference between semaphores and mutex provided by pthread library ?
This two articles explain great details about mutex vs semaphores Also this stack overflow answer tells the similar answer.