Changes between Version 35 and Version 36 of LightweightConcurrency


Ignore:
Timestamp:
May 18, 2012 3:56:18 PM (3 years ago)
Author:
kc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LightweightConcurrency

    v35 v36  
    111111}}} 
    112112 
    113 We expect every SCont to belong to a scheduler.  
     113Abstractly, given an SCont, the scheduleSContAction appends the SCont to a scheduler. The yieldControlAction picks an SCont from a scheduler and switches to it. In order to make the ideas more concrete, let us assume that we have a very simple round-robin scheduler, implemented as a `PVar [SCont]`. One possible implementation of scheduler actions for this scheduler is given below. 
     114 
     115{{{ 
     116scheduleSContAction :: SCont -> PTM ()  
     117scheduleSContAction sc = do 
     118  sched :: PVar [SCont] <- -- get sched  
     119  contents :: [SCont] <- readPVar sched  
     120  writePVar $ contents ++ [sc] 
     121 
     122yieldControlAction :: PTM ()  
     123yieldControlAction = do 
     124  sched :: PVar [SCont] <- -- get sched  
     125  contents :: [SCont] <- readPVar sched  
     126  case contents of 
     127    x:tail -> do {  
     128      writePVar $ contents tail;  
     129      switchTo x -- DOES NOT RETURN 
     130    }  
     131    otherwise -> ... 
     132}}} 
     133 
     134 
    114135 
    115136== Capabilities and Tasks ==