[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Let's throw out SCM_NEWCELL
From: |
Chris Cramer |
Subject: |
Re: Let's throw out SCM_NEWCELL |
Date: |
Fri, 7 Sep 2001 15:20:59 -0500 |
User-agent: |
Mutt/1.2.5i |
On Fri, Sep 07, 2001 at 02:50:37AM +0200, Dirk Herrmann wrote:
> The reason that I have had problems with the idea that all but one thread
> should go asleep during gc is, that I had no idea how this could be
> realized: What about threads that are waiting for a mutex? What about
> threads that are waiting for input?
It's very enlightening to look at the way the Boehm GC handles this.
What they do is have the garbage collector send a signal to every
thread. The signal handler stores the current stack pointer and then
calls sem_post() (to notify the collector that the thread has stopped) and
sigsuspend(). The garbage collector calls sem_wait() for every thread,
and everything is stopped.
To answer your questions, threads that are waiting for a mutex or input
would be in a sigsuspend() (for a mutex) or a read()/select()/etc. (for
input) call, so they would receive the signal, go to sleep, then wake up,
and go back to what they were doing.
This is just for Linux, though. I haven't looked at how they deal with
it on other systems.
--
C. Ray C. aka Christopher Cramer
address@hidden
http://www.pyro.net/~crayc/