On 16 May 2011 19:56, Simon Marlow <marlowsd@gmail.com> wrote:
On 13/05/2011 21:12, Bernie Pope wrote:
Could you please point me to more information about the sequential
consistency of IORefs? I was looking for something about this recently
but couldn't find it. I don't see anything in the Haddock for Data.IORef.
Yes, it's not actually documented as far as I know, and we should fix that.
But if you think about it, sequential consistency is really the only sensible policy: suppose one processor creates a heap object and writes a reference to it in the IORef, then another processor reads the IORef. The writes that created the heap object must be visible to the second processor, otherwise it will encounter uninitialised memory and crash. So sequential consistency is necessary to ensure concurrent programs can't crash.
For some background there was a discussion about this on the haskell-prime mailing list a few years ago, I think.