Date: Mon, 31 Mar 2003 17:20:52 -0500 (EST) From: Andrew Gallatin <gallatin@cs.duke.edu> To: Julian Elischer <julian@elischer.org> Cc: freebsd-arch@FreeBSD.org Subject: RE: cv_timedwait() & exiting procs Message-ID: <16008.48964.858472.638793@grasshopper.cs.duke.edu> In-Reply-To: <Pine.BSF.4.21.0303311257550.52134-100000@InterJet.elischer.org> References: <XFMail.20030331155046.jhb@FreeBSD.org> <Pine.BSF.4.21.0303311257550.52134-100000@InterJet.elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Julian Elischer writes: > > Some comments to your thoughts.. It would be a valid thought to allow > the syscall to complete if the sleep completed. but why? Also, Maybe the > test should also test if we are: > > 1/ threading > and > 2/ not the thread that is actually DOING the exit() > (though exit doesn't do any sleeps that I KNOW of) That would be nice, if I understand what you're saying. The scenario that I'm in is that I have character driver. At certain points, we send "commands" to the the device and sleep on a cv. When the device completes the command, it interrupts the host and the interrupt handler does a cv_signal. If the device does not respond after some seconds, we consider the device dead. One of these commands is issued when the device is closed. The problem occurs when an application does not call close himself, rather he just exits, and our driver's close entry point is called from the exit() code path. The "command" associated with device closes is issued in the context of this (single threaded) process. All is well, and the device responds. The interrupt happens. cv_signal() is called. But: cv_timedwait() then returns with EWOULDBLOCK. Because EWOULDBLOCK is returned, the driver assumes the timeout has been exceeded and device has gone dead. Sure, this is easy enough for me to fix in the driver code, but it really makes FreeBSD's condvar interface look busted.. I was thinking that we could only return an error because of P_WEXIT being set if P_WEXIT was not set when the cv call was entered. Drew
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16008.48964.858472.638793>