Changes between Version 64 and Version 65 of LightweightConcurrency
- Timestamp:
- 05/20/12 16:20:27 (12 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
LightweightConcurrency
v64 v65 260 260 == Parallelism and System Threads == 261 261 262 Whatever be the concurrency model, we would like to retain the non-programmatic control over parallelism (using +RTS -N). Just like in the current system, this runtime parameter controls the maximum number of capabilities. Cores are system resources and hence, the control over their allocation to different processes should be a property of the context under which the programs are run. The concurrency substrate exposes the primitive 263 264 {{{ 262 Whatever be the concurrency model, we would like to retain the non-programmatic control over parallelism (using +RTS -N). Just like in the current system, this runtime parameter controls the maximum number of capabilities. Cores are system resources and hence, the control over their allocation to different processes should be a property of the context under which the programs are run. The concurrency substrate exposes the following primitives 263 264 {{{ 265 getNumCapabilities :: IO Int 266 getCurrentCapability :: PTM Int 267 265 268 newCapability :: SCont -> IO () 266 269 }}} 267 270 268 whichruns the given SCont on a free capability. If there are no free capabilities, a runtime error is raised. A typical, initial task spawned on another core would pull work from the scheduler and switch to it. For example,271 Primitive `newCapability` runs the given SCont on a free capability. If there are no free capabilities, a runtime error is raised. A typical, initial task spawned on another core would pull work from the scheduler and switch to it. For example, 269 272 270 273 {{{ … … 277 280 }}} 278 281 282 When a program boots up with `N` capabilities, it can choose to create `N-1` additional capabilities using the primitive `newCapability` which run `initialTask`. 283 279 284 === Task Model === 280 285 … … 286 291 287 292 {{{ 288 getNumCapabilities :: 289 setSContCapability :: SCont -> Int -> IO () 290 getSContCapability :: SCont -> PTM Int 293 setSContCapability :: SCont -> Int -> IO () 294 getSContCapability :: SCont -> PTM Int 291 295 }}} 292 296
