Changes between Version 19 and Version 20 of Commentary/Rts/Scheduler
- Timestamp:
- 05/20/10 03:05:31 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Commentary/Rts/Scheduler
v19 v20 35 35 Haskell threads are much lighter-weight (at least 100x) than OS threads. 36 36 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. 37 When 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]). 42 38 43 39 The RTS provides a platform-independent abstraction layer for OS … … 66 62 Source files: [[GhcFile(rts/Task.h)]], [[GhcFile(rts/Task.c)]] 67 63 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`:64 A 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`: 69 65 70 66 {{{ 71 67 Task *myTask (void); 72 68 }}} 69 70 The `myTask` function is implemented using thread-local storage. 73 71 74 72 The 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`.
