[Haskell-cafe] GHC, odd concurrency space leak

Bulat Ziganshin bulat.ziganshin at gmail.com
Sat Apr 17 07:35:40 EDT 2010


Hello Jason,

Saturday, April 17, 2010, 2:00:04 AM, you wrote:


> Well, I think Bulat correctly characterized the non-termination
> aspect.  I didn't think the cooperative aspect of threading applied
> with the threaded RTS, so I'm not 100% sure I believe his
> characterization, but otherwise it seems like a reasonable
> explanation. 

it's a well known side of ghc green threads implementation. read notes
in sources of Control.Concurrent module:

The concurrency extension for Haskell is described in the paper
/Concurrent Haskell/
<http://www.haskell.org/ghc/docs/papers/concurrent-haskell.ps.gz>.

Concurrency is "lightweight", which means that both thread creation
and context switching overheads are extremely low.  Scheduling of
Haskell threads is done internally in the Haskell runtime system, and
doesn't make use of any operating system-supplied thread packages.


      GHC implements pre-emptive multitasking: the execution of
      threads are interleaved in a random fashion.  More specifically,
      a thread may be pre-empted whenever it allocates some memory,
      which unfortunately means that tight loops which do no
      allocation tend to lock out other threads (this only seems to
      happen with pathological benchmark-style code, however).



-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list