Changes between Version 136 and Version 137 of LightweightConcurrency


Ignore:
Timestamp:
Apr 25, 2013 7:29:16 PM (15 months ago)
Author:
kc
Comment:

Fixed references that had been pointing to TracSource to github

Legend:

Unmodified
Added
Removed
Modified
  • LightweightConcurrency

    v136 v137  
    216216Here, the thread that invokes forkIO initializes the new SCont (`ns`) with its own scheduler actions, and appends it to the scheduler. After the newly created SCont finishes execution, the control must switch to another thread in the scheduler. This is captured by the `epilogue`. 
    217217 
    218 A full implementation of a round-robin scheduler can be found [source:libraries/lwconc/LwConc/Concurrent.hs?rev=76dc667761e38fec47e7b1aba27bb4c499fd7636 here]. This scheduler has one queue per capability. Work is shared among the capabilities by spawning threads in a round-robin fashion on the capabilities. 
     218A full implementation of a round-robin scheduler can be found [https://github.com/ghc/ghc/blob/ghc-lwc2/libraries/lwconc/LwConc/ConcurrentList.hs here]. This scheduler has one queue per capability. Work is shared among the capabilities by spawning threads in a round-robin fashion on the capabilities. 
    219219 
    220220=== MVars === 
     
    257257If the MVar is full with a pending writer, we first fill the hole with the value. Then, MVar's status is updated with the enqueued value and the rest of the writers. Finally, we execute the dequeued PTM action to place the writer into its corresponding scheduler. 
    258258 
    259 Notice that just like yield and forkIO, takeMVar is scheduler agnostic; the MVar implementation is cleanly separated from the scheduler implementation. Moreover, the same MVar might be shared between threads from different schedulers since they utilize the uniform scheduler interface. Since the scheduler actions are PTM actions, actions from different schedulers can be composed together elegantly and simplifies reasoning about synchronization. An implementation of a MVar can be found [source:libraries/lwconc/LwConc/MVar.hs?rev=76dc667761e38fec47e7b1aba27bb4c499fd7636 here]. 
    260  
    261 As an aside, the race condition in [http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent-MVar.html#v%3AswapMVar swapMVar] can be [source:libraries/lwconc/LwConc/MVar.hs?rev=a51ce194ecaf598ded3cdbf065b1a470e029ccab#L89 eliminated] with the help of PTM abstraction. Thus, PTM abstraction makes it easy to construct correct concurrent data-structures.  
     259Notice that just like yield and forkIO, takeMVar is scheduler agnostic; the MVar implementation is cleanly separated from the scheduler implementation. Moreover, the same MVar might be shared between threads from different schedulers since they utilize the uniform scheduler interface. Since the scheduler actions are PTM actions, actions from different schedulers can be composed together elegantly and simplifies reasoning about synchronization. An implementation of a MVar can be found [https://github.com/ghc/ghc/blob/ghc-lwc2/libraries/lwconc/LwConc/MVarList.hs here]. 
     260 
     261As an aside, the race condition in [http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent-MVar.html#v%3AswapMVar swapMVar] can be [https://github.com/ghc/ghc/blob/ghc-lwc2/libraries/lwconc/LwConc/MVarList.hs#L110 eliminated] with the help of PTM abstraction. Thus, PTM abstraction makes it easy to construct correct concurrent data-structures.  
    262262 
    263263== System Threads and Parallelism ==