[RFC] Implement cv_wait_nolock(), for emulation of SGI's sv_wait()

John Baldwin jhb at freebsd.org
Thu Dec 8 06:57:13 PST 2005


On Wednesday 07 December 2005 05:43 pm, Craig Rodrigues wrote:
> Hi,
>
> As part of the XFS for FreeBSD project, Alexander Kabaev
> implemented a cv_wait_nolock() function for compatibility
> with SGI's sv_wait() call:
> http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fna
>me=/usr/share/catman/p_man/catD/SV_WAIT.z
>
> sv_wait() waits on a synchronization variable, the lock must be held
> before the call is entered, but the lock is not held when sv_wait() is
> exited.
>
> Is this patch OK to go into FreeBSD?
> Comments?

As I said on IRC, I'm not a big fan of this or PDROP, but PDROP is in the 
tree.  Note that you could implement sv_wait() using the existing primitives 
via:

sv_wait()
{
	cv_wait()
	mtx_unlock()
}

If you do stick with cv_wait_nolock(), _please_ don't duplicate a whole bunch 
of code by implement cv_wait() like so:

cv_wait()
{
	cv_wait_nolock()
	mtx_lock()
}

Note that currently you have a bug in the cold || panicstr case in that the 
function doesn't drop the lock.

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-arch mailing list