[Haskell-cafe] Re: Thread scheduling and GHC.Conc

Simon Marlow marlowsd at gmail.com
Fri Dec 19 04:43:38 EST 2008

Jake Foell wrote:
> using ghc v6.8.2
> Problem:
> I am creating a program that forks two other lightweight threads.  One
> of the forked threads seems to be stuck or dead after running
> successfully for a non-trivial amount of time.  I am receiving no
> error messages.
> Questions:
> What is the best way to diagnose this problem? (perhaps a ghc upgrade to
> a version that includes processStatus?)
> Does the runtime system ensure that no thread will starve for processor
> time?
> My initial diagnosis:
> by looking at log files that this program produces, it seems that the
> thread in question is failing while receiving a response from a server.
> Here is a simplified exerpt:
>         h <- connectTo server port
>         appendFile file "Connection Established\n"
>         hPutStr h httpRequestString
>         hFlush h
>         reply <- hGetContents h
>         appendFile file reply
> If I look at the tail of file that is created, I see something similar
> to this:
>         ...
>         Connection Established
>         here is the response...
>         Connection Established
> Answers to my questions and/or any advice would be appreciated. thanks

You might be able to find your problem by compiling the program with -debug 
and running it with +RTS -Ds.  This produces debugging output from the 
scheduler - it's intended mainly for debugging the RTS and has a lot of 
info that won't make much sense to you, but it might help you find the 
problem.  If you're curious about what the RTS is doing, there are a host 
of other -D<something> debugging options available when you compile with 
-debug, use +RTS -? to list them.


More information about the Haskell-Cafe mailing list