Add a new primitive forkOn#, for forking a thread on a specific Capability
authorSimon Marlow <simonmar@microsoft.com>
Mon, 27 Mar 2006 12:41:51 +0000 (12:41 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Mon, 27 Mar 2006 12:41:51 +0000 (12:41 +0000)
commitc520a3a2752ffcec5710a88a8a2e219c20edfc8a
tree6bdf5c64fd866885247ae89d04f80f4ead7a29ce
parent5ed93b107550cc10fda7ae187de65da1a4b24d87
Add a new primitive forkOn#, for forking a thread on a specific Capability

This gives some control over affinity, while we figure out the best
way to automatically schedule threads to make best use of the
available parallelism.

In addition to the primitive, there is also:

  GHC.Conc.forkOnIO :: Int -> IO () -> IO ThreadId

where 'forkOnIO i m' creates a thread on Capability (i `rem` N), where
N is the number of available Capabilities set by +RTS -N.

Threads forked by forkOnIO do not automatically migrate when there are
free Capabilities, like normal threads do.  Still, if you're using
forkOnIO exclusively, it's a good idea to do +RTS -qm to disable work
pushing anyway (work pushing takes too much time when the run queues
are large, this is something we need to fix).
ghc/compiler/prelude/primops.txt.pp
ghc/includes/StgMiscClosures.h
ghc/includes/TSO.h
ghc/rts/PrimOps.cmm
ghc/rts/Schedule.c
ghc/rts/Schedule.h