Changes between Version 21 and Version 22 of Commentary/Rts/Scheduler


Ignore:
Timestamp:
Mar 10, 2013 12:58:05 AM (13 months ago)
Author:
ezyang
Comment:

start incorporating things from my blog post

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Rts/Scheduler

    v21 v22  
    4545 
    4646A Haskell thread is represented by a Thread State Object 
    47 ([wiki:Commentary/Rts/Storage/HeapObjects#ThreadStateObjects TSO]). There are 
     47([wiki:Commentary/Rts/Storage/HeapObjects#ThreadStateObjects TSO]). These objects are ''garbage-collected'', like other closures in Haskell.  The TSO, along with the stack allocated with it (STACK), constitute the primary memory overhead of a thread.  Default stack size, in particular, is controlled by the GC flag {{{-ki}}}, and is 1k by default (Actually, your usable stack will be a little smaller than that because this size also includes the size of the {{{StgTSO}}} struct, so that a lot of allocated threads will fit nicely into a single block.) There are 
    4848two kinds of Haskell thread: 
    4949 
     
    5959   {{{Control.Concurrent.forkIO}}}.  Foreign calls made by an unbound 
    6060   thread are made by an arbitrary OS thread. 
     61 
     62Initialization of TSOs is handled in {{{createThread}}} in [[GhcFile(rts/Threads.c)]]; this function is in turn invoked by {{{createGenThread}}}, {{{createIOThread}}} and {{{createStrictIOThread}}} in [[GhcFile(rts/RtsAPI.c)]]. These functions setup the initial stack state, which controls what the thread executes when it actually gets run. These functions are the ones invoked by the {{{fork#}}} and other primops (recall entry-points for primops are located in [[GhcFile(rts/PrimOps.cmm)]]). 
    6163 
    6264== Tasks ==