caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus.mottl@gmail.com>
To: OCaml List <caml-list@yquem.inria.fr>
Subject: [Caml-list] Threads and "transaction isolation" in OCaml
Date: Thu, 15 Aug 2013 17:57:14 -0400	[thread overview]
Message-ID: <CAP_800r3q72mPT4L9onnvBL6X0CD63F9f-7t=GVA7GcFMrD3vw@mail.gmail.com> (raw)

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

             reply	other threads:[~2013-08-15 21:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-15 21:57 Markus Mottl [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_800r3q72mPT4L9onnvBL6X0CD63F9f-7t=GVA7GcFMrD3vw@mail.gmail.com' \
    --to=markus.mottl@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).