pthreads mutex vs semaphore

semaphores have a synchronized counter and mutex’s are just binary (true / false).

A semaphore is often used as a definitive mechanism for answering how many elements of a resource are in use — e.g., an object that represents n worker threads might use a semaphore to count how many worker threads are available.

Truth is you can represent a semaphore by an INT that is synchronized by a mutex.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)