Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 02 Mar 2004 07:20:40 +0800
From:      David Xu <davidxu@freebsd.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        threads@freebsd.org
Subject:   Re: Proper algorithm for return values from sleep
Message-ID:  <4043C548.4080608@freebsd.org>
In-Reply-To: <200403011555.28960.jhb@FreeBSD.org>
References:  <200402271455.38197.jhb@FreeBSD.org> <403FEE22.2040507@freebsd.org> <200403011555.28960.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote:
> On Friday 27 February 2004 08:25 pm, David Xu wrote:
> 
>>John Baldwin wrote:
>>
>>>As part of my sleep queue work, I found that msleep() and the cv_wait()
>>>functions have differing semantics for return vales.  It appears that at
>>>least some of the early changes KSE made to msleep() were ported to cv's
>>>but not later cleanups.  Specifically, in msleep(), if we are awakened
>>>while checking for signals but we didn't find a signal, we prefer a
>>>timeout-related return value over a signal-related value.
>>
>>Yes, I think cv and msleep code should be synchronized.
>>
>>
>>>Secondly, cv's don't really handle
>>>td_intrval very well at all.
>>
>>It is a bug. :-(
>>
>>
>>>It has one hard-coded override for the P_EXIT
>>>case but that's it.
>>
>>I think it should includes P_SINGLE_EXIT, P_WEXIT is set when there is
>>only one thread in process (see exit1() ). both msleep and cv are
>>incorrect in the case.
>>
>>Are you fixing these bugs ?
> 
> 
> Well, I'll fix them if I can figure out what the correct algorithm should 
> be. :)  Do you think you could sketch it out in psuedo-code?
> 
I think msleep and cv code may only care if it should be blocked or not,
but don't care which signal should be returned from sleepq, sleepq would 
return zero, EINTR, EAGAIN or EWOULDBLOCK, TDF_INTERRUPT should be
handled in sleepq_catch_signals(), and the function may only return 
above values. I am busy at thread debugger code, and don't have
time to fix it.




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