- Nov 6, 2004
- 324
- 0
- 0
Hi, I'm working on an assignment for my Operating Systems class in which we are to implement a solution to the Producer-Consumer Problem using pthreads. I am not asking for ways to solve this, rather I have a question about the pthreads & semaphores themselves. We are being asked to utilize binary semaphores as well as counting ones.
I understand why we need the counting semaphores, but why do we need to use binary ones when the pthreads are already going to be requesting mutex locks using the function pthread_mutex_lock()? It seems almost as if the request for the semaphore (sem_wait()) is superfluous. Perhaps I am not understanding the difference between mutex locks. Can someone help clarify?
Thanks in advance.
I understand why we need the counting semaphores, but why do we need to use binary ones when the pthreads are already going to be requesting mutex locks using the function pthread_mutex_lock()? It seems almost as if the request for the semaphore (sem_wait()) is superfluous. Perhaps I am not understanding the difference between mutex locks. Can someone help clarify?
Thanks in advance.
