Changes between Version 88 and Version 89 of LightweightConcurrency


Ignore:
Timestamp:
May 22, 2012 10:21:15 PM (3 years ago)
Author:
kc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LightweightConcurrency

    v88 v89  
    365365If an SCont is blocked with status `SContSwitched Yielded` has become unreachable, we run the SCont's finalizer, if installed. 
    366366 
    367 == Safe Foreign Calls == 
     367=== Preemptive Scheduling === 
     368 
     369=== Safe Foreign Calls === 
    368370 
    369371A [http://community.haskell.org/~simonmar/papers/conc-ffi.pdf safe foreign call] does not impede the execution of other Haskell threads on the same scheduler, if the foreign call blocks. Before performing the foreign call, the task, say `T1`, releases the capability that it currently owns. This might wake up other tasks which are waiting to acquire a free capability. After the foreign call has completed, `T1` tries to reacquire the last owned capability. In the fast path, the foreign call quickly completes and `T1` reacquires the capability. In the slow path, some other task, say `T2`, acquires the capability. 
    370372 
    371 === Slow-path in Vanilla RTS === 
     373==== Slow-path in Vanilla RTS ==== 
    372374 
    373375In the vanilla RTS, `T2` will pick the next available thread from the current capability's run queue and resume execution. When `T1` eventually completes the foreign call, it tries to reacquire the capability. Thus, performing a safe-foreign call does not block all the threads on that capability.  
    374376 
    375 === Slow-path in LWC RTS === 
     377==== Slow-path in LWC RTS ==== 
    376378 
    377379The fast path in the LWC implementation is the same as vanilla implementation. However, in the slow path, we need a way for `T2` to resume the scheduler, and a way for `T1` to join the scheduler when the foreign call execution eventually completes. Assume that the Haskell thread that is running on the task `T1` is `t1`. We utilize the yieldContrlAction of `t1` to enable `T2` to resume execution of other threads on the scheduler. When `T1` eventually resumes execution after the foreign call, it finds that it has lost the race to acquire the capability to T2. At this point, `T1` executes `t1`'s scheduleSContAction to join the scheduler. 
    378380 
    379 == Asynchronous Exceptions == 
    380  
    381 == PTM retry == 
    382  
    383 == Black-hole Handling == 
     381=== Asynchronous Exceptions === 
     382 
     383=== PTM retry === 
     384 
     385=== Black-hole Handling === 
    384386 
    385387== Related Work ==