caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oleg@pobox.com
To: dmitry.bely@gmail.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Resumable exceptions in plain OCaml
Date: Mon, 19 Jun 2006 14:40:12 -0700 (PDT)	[thread overview]
Message-ID: <20060619214012.D3581AC97@Adric.metnet.fnmoc.navy.mil> (raw)
In-Reply-To: <90823c940606180201h186824fbpe3b3d1976cc581fb@mail.gmail.com>


> Is your implementation thread-safe? My impression is it doesn't seems
> to be.

Interaction of dynamic binding and threading is quite an interesting
topic, which has been the subject of several papers (including ours,
which has been just accepted for ICFP). The implementation in
resumable.ml used so-called shallow-binding -- this is the common
technique of implementing dynamic binding in Lisp and Scheme
systems. Alas, it doesn't well generalize to a multi-threading
environment. For multi-threading, a better approach is dealing with
the stack of handlers explicitly, keeping it in the thread-local
storage. Incidentally, this is the approach adopted in Scheme48, which
has a quite an advanced multi-threading system with user-defined
schedulers, channels and software transactional memory.

The best approach, in my opinion, is to `bind' exceptions handlers to
the stack (because the stack is the best `representation' of the
dynamic context). It is very simple (albeit requiring a small bit of C
code in the library of resumable exceptions) to get hold of OCaml's
own exception handlers. Also, we can use delimited continuations to
implement dynamic binding. That too solves all the problems. Alas,
currently delimited continuations are available only for byte code.

In any event, these performance improvement and generalizations will
not change the published interface of resumable exceptions.


      reply	other threads:[~2006-06-19 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-14 22:54 oleg
2006-06-14 23:46 ` [Caml-list] " Erik de Castro Lopo
2006-06-16 21:33 ` Christophe Raffalli
2006-06-16 21:41   ` Christophe Raffalli
2006-06-17  7:45   ` oleg
2006-06-18  9:01 ` Dmitry Bely
2006-06-19 21:40   ` oleg [this message]

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=20060619214012.D3581AC97@Adric.metnet.fnmoc.navy.mil \
    --to=oleg@pobox.com \
    --cc=caml-list@inria.fr \
    --cc=dmitry.bely@gmail.com \
    /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).