caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Threads and "transaction isolation" in OCaml
@ 2013-08-15 21:57 Markus Mottl
  2013-08-16  1:28 ` John F Carr
  2013-08-16  8:46 ` Török Edwin
  0 siblings, 2 replies; 9+ messages in thread
From: Markus Mottl @ 2013-08-15 21:57 UTC (permalink / raw)
  To: OCaml List

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.

E.g. pattern-matches, array and record field assignments, etc., can be
safely chained together in one "transaction" without having to fear
that another thread will interrupt them.  This is extremely useful for
optimizing certain applications where lock acquisitions might just be
too expensive.

There already are some corner cases where things may be
platform-dependent, e.g. calling functions tail-recursively that take
more arguments than there are available CPU-registers.  In that case
the compiler may pass arguments by allocating blocks on the heap.  But
I think people that care about such obviously brittle semantics know
where to be careful.

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.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-08-19 14:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-15 21:57 [Caml-list] Threads and "transaction isolation" in OCaml Markus Mottl
2013-08-16  1:28 ` John F Carr
2013-08-16  2:55   ` Markus Mottl
2013-08-16  8:46 ` Török Edwin
2013-08-16 16:07   ` Markus Mottl
2013-08-17  0:06     ` Yaron Minsky
2013-08-19  6:10       ` Mark Shinwell
2013-08-19 14:18         ` Markus Mottl
2013-08-19  7:33     ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).