GHC supports Concurrent Haskell by default, without requiring a
special option or libraries compiled in a certain way. To get access to
the support libraries for Concurrent Haskell, just import
Control.Concurrent
. More information on Concurrent Haskell is provided in the documentation for that module.
Optionally, the program may be linked with
the -threaded
option (see
Section 4.12.6, “Options affecting linking”. This provides two benefits:
It enables the -N
RTS option to be
used, which allows threads to run in
parallel
on a
multiprocessor
or
multicore
machine. See Section 4.15, “Using SMP parallelism”.
If a thread makes a foreign call (and the call is
not marked unsafe
), then other
Haskell threads in the program will continue to run
while the foreign call is in progress.
Additionally, foreign export
ed
Haskell functions may be called from multiple OS
threads simultaneously. See
Section 8.2.4, “Multi-threading and the FFI”.
The following RTS option(s) affect the behaviour of Concurrent Haskell programs:
-Cs
Sets the context switch interval to s
seconds. A context switch will occur at the next heap block
allocation after the timer expires (a heap block allocation occurs
every 4k of allocation). With -C0
or
-C
, context switches will occur as often as
possible (at every heap block allocation). By default, context
switches occur every 20ms.