Re: Changeset 0306c5a64775

Will Noble <[email protected]> Tue, 10 Jan 2012 18:54:30 -0800
Newsgroups gmane.lisp.scheme.scheme48
Message-ID <[email protected]>
On Tue, Jan 10, 2012 at 10:11:26AM +0000, Robert Ransom wrote:
> On 2012-01-08, Will Noble <[email protected]> wrote:
> > This suggests to me that the RTS should at least keep track of the number of
> > threads waiting for a signal, and POSIX could increment/decrement that
> > number. Then there could be a function WAITING-ON-OS-SIGNAL? that ROOT-WAIT
> > could check.
> 
> Would a counter be sufficient for this?  I see some use of weak
> pointers in scheme/posix/signal.scm, so I really have no idea whether
> we could safely use that optimization (i.e. look at a counter instead
> of the thread queues themselves), even if we didn't need a more
> general solution.

Yes. A sleeping thread can't wait for a signal so a counter works just as
well as looking at the thread queue. It's less optimization than
convenience. With the approach I outlined in the previous message you might
equally well register the actual thread queues with the RTS and have
ROOT-WAIT go through them to see if a thread somewhere is waiting for a
signal, but a counter does the same thing.

Regarding the weak pointer usage in signal.scm: those map signal numbers to
signal representations. If, say, you have a signal 5 in the system, the
mapping returns the existing object when asked for signal 5. However, if
everyone else loses their reference to that object, you don't want the
abstract concept of "5" to keep it around forever without being
garbage-collected. It's not something that would break the counter shortcut.

Best,
Will