[Haskell-cafe] Re: Waiting for thread to finish

Bryan O'Sullivan bos at serpentine.com
Wed Nov 28 17:30:07 EST 2007


Andrew Coppin wrote:
> Dan Weston wrote:
>> Silly or not, if I compile with -threaded, I always link in the 
>> one-liner C file:
>>
>>   char *ghc_rts_opts = "-N2";
> 
> Ah... you learn something useful every day! I was going to ask on IRC 
> whether there's any way to do this - but now I don't need to bother. :-)

But wait, there's more!  If you're using the threaded RTS, you often 
need to know how many threads you can run concurrently, for example to 
explicitly split up a compute-bound task.  This value is exposed at 
runtime by the numCapabilities variable in the GHC.Conc module.

http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/GHC-Conc.html#v%3AnumCapabilities

This variable is new in GHC 6.8.1 (thanks, Simon!), so don't try to use 
it with an older release.

	<b


More information about the Haskell-Cafe mailing list