[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Thread starvation with mutex



David Lloyd wrote:

On Mon, 9 Feb 2004, Gary S. Robertson wrote:

System/library function calls should be engineered to reliably perform
the operations their names and documentation suggest will occur when
they are invoked - otherwise they should return with an error.  In this
case, if the programmer calls pthread_mutex_unlock, then most likely the
intent is to yield the mutex to the next waiting pthread, if any.


I disagree, I would think that the intent for pthread_mutex_unlock would
be to unlock the mutex according to the way POSIX Threads are supposed to
unlock mutexes. If I want to yield a mutex to another thread, I would use a condition variable.


- D

This would be appropriate if the desire is to yield the protected resource to a specific thread... it shouldn't be necessary to incur the extra overhead of a condition variable or a second system call if the intent is simply to the next unspecified thread which might be waiting on it.







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]