Changes between Version 19 and Version 20 of Commentary/Rts/Scheduler


Ignore:
Timestamp:
May 20, 2010 10:05:31 AM (5 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Rts/Scheduler

    v19 v20  
    3535Haskell threads are much lighter-weight (at least 100x) than OS threads.
    3636
    37 When running on an SMP, we use a fixed number of OS threads for
    38 running Haskell code, typically chosen to be the the same as the
    39 number of CPU cores in the machine.  There may be more than this
    40 number of OS threads in the runtime, but only this number will be
    41 executing Haskell code at any one time.
     37When running on an SMP, we begin by creating the number of OS threads specified by the `+RTS -N` option, although during the course of running the program more OS threads might be created in order to continue running Haskell code while foreign calls execute.  Spare OS threads are kept in a pool attached to each `Capability` (see [#Capabilities]).
    4238
    4339The RTS provides a platform-independent abstraction layer for OS
     
    6662Source files: [[GhcFile(rts/Task.h)]], [[GhcFile(rts/Task.c)]]
    6763
    68 A Task is a further layer of abstraction over an OS thread.  One `Task` is created for each OS thread known to the runtime.  To get the `Task` associated with with the current OS thread, use the function `myTask`:
     64A Task is a further layer of abstraction over an OS thread.  One `Task` structure is created for each OS thread known to the runtime.  To get the `Task` associated with with the current OS thread, use the function `myTask`:
    6965
    7066{{{
    7167  Task *myTask (void);
    7268}}}
     69
     70The `myTask` function is implemented using thread-local storage.
    7371
    7472The Task contains a mutex and a condition variable used when OS threads in the runtime need to synchronise with each other or sleep waiting for a condition to occur.  The `Task` also points to the `Capability` that the `Task` currently owns (`task->cap`), or `NULL` if the `Task` does not currently own a `Capability`.