Like
forkIO, but lets you specify on which capability the
thread should run. Unlike a
forkIO thread, a thread created by
forkOn will stay on the same capability for its entire lifetime
(
forkIO threads can migrate between capabilities according to
the scheduling policy).
forkOn is useful for overriding the
scheduling policy when you know in advance how best to distribute the
threads.
The
Int argument specifies a
capability number (see
getNumCapabilities). Typically capabilities correspond to
physical processors, but the exact behaviour is
implementation-dependent. The value passed to
forkOn is
interpreted modulo the total number of capabilities as returned by
getNumCapabilities.
GHC note: the number of capabilities is specified by the
+RTS
-N option when the program is started. Capabilities can be fixed
to actual processor cores with
+RTS -qa if the underlying
operating system supports that, although in practice this is usually
unnecessary (and may actually degrade performance in some cases -
experimentation is recommended).