Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 May 2003 13:48:45 -0500
From:      Greg <greg@codeconcepts.com>
To:        freebsd-smp@freebsd.org
Subject:   spinlocks and cv_wait()
Message-ID:  <200305061848.h46Imjva068831@gromit.codeconcepts.com>

next in thread | raw e-mail | index | archive | help

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
bottom half.

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
greatly appreciated.

Thanks in advance!
Greg


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@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) 





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305061848.h46Imjva068831>