On 08/16/2013 12:57 AM, Markus Mottl wrote: > Hi, > > I just wondered how much we can rely on current OCaml-semantics where > context-switches are impossible as long as there are no allocations. I wrote a little test program and this is not true for bytecode -vmthread, but seems to work for bytecode -thread and native -thread: $ ocamlfind ocamlc race.ml -package threads -vmthread -linkpkg -o race && ./race started Check OK worker 2 OK worker 3 OK worker 4 OK worker 5 OK worker 7 OK worker 8 OK worker 9 OK worker 10 OK worker 11 OK worker 12 OK worker 13 OK worker 14 OK worker 0 OK worker 1 OK worker 6 OK worker 15 OK Array sum inconsistent: -33 > > Anyway, is it considered reasonably future-safe to write code of that > sort? I'd rather not have new compiler optimizations, etc., interfere > with these assumptions in the near future. I'd consider this very fragile as you'd need to know the implementation details of every function you call (or only calling your own safe functions). I was surprised to find out that even Array.fold_left creates a temporary ref for example. Best regards, --Edwin