cv_timedwait() & exiting procs

Robert Watson rwatson at freebsd.org
Mon Mar 31 13:05:47 PST 2003


On Mon, 31 Mar 2003, Andrew Gallatin wrote:

> FreeBSD's cv_timedwait() function helpfully notices that a process is
> exiting and returns EWOULDBLOCK if it is. 
> 
> However, if you call cv_timedwait() in the context of a process which is
> already exiting, you always get back EWOULDBLOCK, regardless of whether
> or not the timeout expired.  Similarly for the cv_wait_sig()  and
> cv_timedwait_sig(), except they set EINTR. 
> 
> Does anyone else consider this behaviour to be a bug?  I think it should
> only return EWOULDBLOCK/EINTR because a process is exiting if the
> process wasn't already exiting when it entered the cv_*wait* routine,
> but perhaps I'm misguided... 

Hmm.  It has always struck me that the nice thing about the SMPng
synchronization primitives is that they implement well-defined anc
consistent semantics in a manner consistent with other implementations of
the same primitives.  I'd rather see the caller test the P flags and
change the arguments to cv_timedwait() than see cv_timedwait() implement
unusual semantics based on process conditions.  Process exiting stuff is a
special case, but only from the perspective of the high level code: I
think I'd be upset to find cv_timedwait() change behavior at a much lower
level (i.e., in vnode handling or last reference socket handling) just
because it happens to run at exit()-time. 

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Network Associates Laboratories




More information about the freebsd-arch mailing list