Why it's dangerous to fork off a new process in Glasgow Haskell

George Russell ger@tzi.de
Wed, 04 Sep 2002 09:15:42 +0200


Alastair Reid wrote:
> 
> > It would be good if there were a way of telling GHC's RTS scheduler
> > "Please don't run any other threads apart from this one until
> > further notice".
> 
> It seems like you're only worried about the threads which interact
> with your servers.  A thread which continues printing prime numbers or
> whatever to the screen probably wouldn't cause problems.
What is "the screen"?  If you mean stdout, it most certainly would cause
problems since stdout of the child process corresponds to the tool's output,
so the tool would appear to emit prime numbers at the start.
> 
> It also sounds like you want to be able to tell the RTS 'and if one of
> the other threads is already talking to the servers, let it finish
> first'.
> 
> In other words, it sounds like the right thing is to protect access to
> the servers with some kind of lock (MVar, Semaphore, etc.).
> 
> Is there a reason why this won't work?
So before I send every character to any external device (and I have quite
a few of them) I have to check an MVar?  No thank you.

It's not just servers, I also have external tools and so on.
[snip]