spinlocks and cv_wait()
greg at codeconcepts.com
Tue May 6 11:48:41 PDT 2003
Hi, I am working on a driver that has data which is accessed by both
the top and bottom. It is a typical situation in which the top half
initiates I/O and then awaits notification of completion by the
The problem seems to be that either that I am misunderstanding something
fundamental in the FreeBSD locking implementation, or perhaps the
implementation of cv_wait() is a bit too restrictive.
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).
As a data point, this code runs correctly on SMP Solaris, AIX, and
FreeBSD-4 (taking into account the different locking APIs, of course).
If anyone out there can shed some light on the problem it would be
Thanks in advance!
P.S. My system is fairly current. My last cvs up didn't turn up
any changes to the locking code.
FreeBSD magenta.cc.codeconcepts.com 5.0-RELEASE-p7 FreeBSD 5.0-RELEASE-p7 #0:
Sat Apr 12 14:04:42 CDT 2003
greg at magenta.cc.codeconcepts.com:/usr/obj/usr/src/sys/MAGENTA i386
Every man's work, whether it be literature or music or pictures or architecture
or anything else, is always a portrait of himself - Samuel Butler (1835-1902)
More information about the freebsd-smp