caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David McClain" <dmcclain@azstarnet.com>
To: <caml-list@inria.fr>
Subject: Threads Library
Date: Wed, 29 Dec 1999 02:41:49 -0700	[thread overview]
Message-ID: <000c01bf51e0$ef8295a0$250148bf@vega> (raw)

I just received a copy of Reppy's new book on "Concurrent ML". I was
delighted to find that the OCAML Threads library incorporates much of his
work with channels and events.

However, unlike CML, (on Windows/NT at least) the GC does not discard
threads hung up on channels that are no longer in use by active threads.
Hence the use of speculative spawning is not safe in WinNT/OCAML. (Early
experiments generated thousands of threads before I had to kill off the
program).

Secondly, it would appear that the semantics of "with_abort" require that
the wrapper function be called ahead of all "with" functions. But
experiments where a with-function raises an exception bypass the actions of
pending "with_abort" functions on non-selected channels. So evidently, one
should not permit the use of uncaught exceptions inside of "with" functions.

Finally, where Reppy's CML uses continuations to effect tail calls, I wonder
about the use of indefinite recursion triggered by a with-function. It would
seem that one should treat composite event lists in much the same manner as
"try-with" when it comes to recursion inside a try (resp. with) clause.
Instead of tail calling from the "with" clause one should return a value to
the outer level of the "sync" or "select", and then "match" on that value
before recursing.

I have implemented a module that provides thread safety, as long as the
above protocols are followed. In effect all events generated by Event.send
and Event.receive are first wrapped in a "with_abort" where the function
spawns a thread to respond to the eventual conjugate operation on the
channel. There are unsafe versions that simply repeat Event.send and
Event.receive for use when it is known that the corresponding thread will
not be ignored forever.

Do I understand the OCAML situation properly?

TIA

David McClain,
Sr. Scientist
Raytheon Systems Co.
Tucson, AZ





             reply	other threads:[~1999-12-30 10:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-29  9:41 David McClain [this message]
2000-01-13  9:32 ` Xavier Leroy
2000-01-15  2:14   ` Dynamic loading and building of shared libraries skaller
2000-01-17  3:59     ` Ian Zimmerman
2000-01-17  8:00     ` STARYNKEVITCH Basile
2000-01-13 19:49 Threads Library Juergen Pfitzenmaier
2004-11-22 21:20 Threads library Ernesto Posse

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='000c01bf51e0$ef8295a0$250148bf@vega' \
    --to=dmcclain@azstarnet.com \
    --cc=caml-list@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).