spinlocks and cv_wait()

Greg greg at codeconcepts.com
Wed May 7 07:44:13 PDT 2003


> > Because the bottom half is a disk I/O interrupt handler, I presume the
> > mutex must be of the MTX_SPIN variety, and therein is the problem.  The
> > top half acquires the mutex, checks the condition, and then calls cv_wait()
> > if the condition is not met.  Unfortunately, cv_wait() checks that the
> > mutex is of the sleeping variety and trips an assert because it isn't
> > (at kern_condvar.c line 240).
> 
> Your first assumption here is wrong.  Interrupt handlers run in a (mostly)
> top-half context and are allowed to use normal mutexes.  MTX_SPIN mutexes
> should be avoided when possible.

Thanks for the clarification.  The mtx_init man page said as much, but
I wasn't 100% certain.  Of course I had tried MTX_DEF, but then the
machine crashed in seemingly unrelated code, so I couldn't be certain
which usage was correct.

-- 

The comfort of a knowledge of the rise above the sky above could
never parallel the challenge of an acquisition in the here and now





More information about the freebsd-smp mailing list