[Haskell-cafe] Re: Debugging concurrent program - no threads
apparently running, but RTS still doing something.
alistair at abayley.org
Thu Feb 22 07:52:16 EST 2007
> > The problem is that when the main thread ends, the RTS doesn't stop
> > for another 6 or so seconds. The only thread that runs this long is
> > the handler (waitFor (secs 8.0)) but it has already been killed. So
> > I'm scratching my head a bit.
> Short answer: use -threaded.
> The runtime is waiting for a worker thread to complete before it can exit; even
> though your Haskell thread has been killed, there is still an OS thread
> executing Sleep() which was started by threadDelay, and this OS thread has to
> complete before the RTS can exit. We should really terminate the thread more
> eagerly, but since this only affects the non-threaded RTS fixing it isn't a high
Sweet, thanks. A note in the docs somewhere about this implementation
detail would be nice; something that says you may want to consider
-threaded because the implementation of threadDelay uses an OS thread.
I suppose the best place would be in the docs for
Control.Concurrent.threadDelay, although perhaps too a mention in
section 4.10.7 of the ghc user's guide, because in there it says:
"Note that you do not need -threaded in order to use concurrency; ..."
It could say
"Note that you do not need -threaded in order to use concurrency
(unless you use threadDelay - see Control.Concurrent for details);
More information about the Haskell-Cafe