On Wed, 9 Sep 2009 01:20:06 +0200
Philippe Wang <philippe.wang.li...@gmail.com> wrote:

> >  let x = Array.make 100 []
> >  let update i n = x.(i) <- n :: x.(i)
> >  let read i = x.(i)
> 
> I don't think you can obtain funny results when you don't put a mutex
> on these two specific "update" and "read".
> What is sure is that "update" function is not atomic because you have
> a value allocation at the right of "<-" (with :: operator), and this
> may trigger garbage collection and/or make the scheduler change the
> running thread.

Yes, that's not a problem.

Thinking that over again it looks like the only issue remaining is the
possibility that compiler can be too smart and cache/reorder memory
operations, but ocamlopt is not of that kind, right?

-- 
 ygrek
 http://ygrek.org.ua

Attachment: pgprlChmh0UhJ.pgp
Description: PGP signature

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to