[Haskell-cafe] Race condition possible?
Peter Verswyvelen
bugfact at gmail.com
Thu Feb 12 18:17:52 EST 2009
Consider the following code
stamp v x = do
t <- getCurrentTime
putMVar v (x,t)
Is it possible - with GHC - that a thread switch happens after the t <-
getCurrentTime and the putMVar v (x,t)?
If so, how would it be possible to make sure that the operation of reading
the current time and writing the pair to the MVar is an "atomic" operation,
in the sense that no thread switch can happen between the two? Would this
require STM?
Thanks again for sharing your wisdom with me :)
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090213/3d599d37/attachment.htm
More information about the Haskell-Cafe
mailing list