[GHC] #4001: Implement an atomic readMVar

GHC ghc-devs at haskell.org
Sat Jun 15 03:43:58 CEST 2013


#4001: Implement an atomic readMVar
-------------------------------------------+--------------------------------
    Reporter:  simonmar                    |       Owner:  ezyang          
        Type:  task                        |      Status:  new             
    Priority:  low                         |   Milestone:  7.6.2           
   Component:  Runtime System              |     Version:  6.12.2          
    Keywords:                              |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple            |     Failure:  None/Unknown    
  Difficulty:  Moderate (less than a day)  |    Testcase:                  
   Blockedby:                              |    Blocking:                  
     Related:                              |  
-------------------------------------------+--------------------------------
Changes (by ezyang):

  * owner:  => ezyang


Comment:

 On a whim, I decided to implement atomicReadMVar. Details:

 * Adds an extra word to the size of StgMVar; someone needs to find out how
 expensive this is.
 * Adds an extra memory dereference to putMVar/tryPutMVar, since they now
 need to check if there are any threads which are waiting on reads.

 Otherwise, it's implemented exactly as Simon described it.

 I still don't know if this is a good idea, but it does seem that a "wake
 all" semantics might be pretty useful for MVars.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4001#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list