| type MVar# s elt -- primitive | | newMVar# :: State# s -> (# State# s, MVar# s elt #) | takeMVar# :: SynchVar# s elt -> State# s -> (# State# s, elt #) | putMVar# :: SynchVar# s elt -> State# s -> State# s
Bad idea to look at the primops. The important things are the MVar type the operations newMVar, takeMVar, putMVar the forkIO operation Their semantics are described (completely I think) in my "Tackling the awkward squad" tutorial. | As another aside, in the hierarchical libraries docs (package base, | Control.Concurrent.MVar) there appears to be an ambiguity: | | readMVar :: MVar a -> IO a | This is a combination of takeMVar and putMVar; ie. it takes the | value from the MVar, puts it back, and also returns it. | | It specifically avoids describing the combination as atomic, so I | am uncertain whether the thread can be pre-empted between the 'take' | and the 'put'? Normally the answer would be yes, but then there is no | benefit from having a separate 'readMVar' to combine the operations, | so I am guessing that it /should/ be atomic. False. readMVar is completely described by readMVar m = do { v <- takeMVar m; putMVar m v; return v } If it gets pre-empted between the take and the put, no matter; anyone trying to take from that same MVar will block. Simon _______________________________________________ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi