[illumos-Developer] webrev: 1039 /usr/lib/smbsrv/smbd prevents suspend

Bill Sommerfeld sommerfeld at hamachi.org
Fri May 27 08:51:30 PDT 2011


On 05/27/11 06:17, Gordon Ross wrote:
> Thanks.  That's interesting re. no mutex hold needed or cv_signal, etc.
> The documentation for cond_signal suggests you should hold the mutex
> which is probably what I was remembering.  (I thought it was required.
> Maybe it was on some other system I used to worked on.)

In most cases it won't matter.  But if you're worried about real-time 
correctness with mutex priority inheritance, there are some cases where 
you get priority inversions (resulting in higher latency and possibly 
even deadlock) if you don't hold the mutex when you do the 
cv_signal/cv_broadcast -- your priority drops when you unlock, and you 
may be preempted before you get to do the wakeup.

The failure case on an N-cpu system involves N+2 threads -- a high 
priority thread waiting, N unrelated medium-priority threads which 
become runnable at just the wrong moment, and a normally low-priority 
thread which holds a mutex and has inherited the high priority of the 
first thread and is about to do a wakeup.

The low-priority thread drops the mutex, drops in priority, and is 
immediately preempted by one of the medium-priority threads before the 
wakeup can happen; the high priority thread is "stuck" until the 
low-priority thread gets to run again, which may not be for a while.

					- Bill



More information about the Developer mailing list