Next: GAML
Up: Literature on Threads in
Previous: Threads in SML
Another approach to adding threads to SML is due to Reppy
[19] in which a running program consists of threads which
communicate and synchronise by passing synchronous messages on typed
channels.
- spawn function takes a function as an argument and
dynamically creates a new thread that evaluates the application of the
argument function.
- channel function dynamically creates a (weakly)
polymorphic channel. SML's Lexical scoping is used to share channels
between threads, and to hide channels from other threads.
- send and accept operations deal with synchronous communications. They complement each other. To communicate to a channel a thread must rendezvous with another thread that wants to do complementary communication on the same channel.
- CSP style rendezvous mechanism with selective communication is
implemented using events . According to Reppy, this achieves a
level of abstraction that ensures security and ease of maintainance.
events are a type of values that represent synchronous
operations. base_events represent communication operations.
receive and transmit functions build on these
base_events . Combinators for associating actions to events and
to build nondeterministic choices of events are provided. wrap
combinator associates the action to an event. choose
combinator builds the non-deterministic choice. A sync
operator is provided to force synchronisation on an event. This
formalism allows a programmer to create first class synchronisation
and communication abstractions. Other synchronous operations like
thread termination, low-level I/O support and time-outs can be
expressed in terms of events . They are wait for
termination, syncOnOutput and syncOnInput for I/O and
waitUntil and timeOut for time-outs. CML has a uniform
mechanism for combining synchronous operations. It provides
guard and wrapAbort combinators to deal with commit
points in communications. Concurrent versions of I/O primitives are
provided.
- CML has been used in interactive systems to build a multi-threaded interface to the X protocol, called eXene , providing similar functions to the Xlib . Another area of application of CML is distributed systems programming. Especially interesting is the use of CML in Nuprl (an interactive proof system for ML) to distribute the parts of a proof among the pool of proof servers across a network of workstations.
- Implementation languages used is SML and its extensions (first-class continuations (for threads) and asynchronous signals (for preemptive scheduling)). Heap based implementations are particularly suited for light-weight threads
(though stack-based ones are also possible).
- A CSP based formal semantics for CML has been given
[20]. Some recent work in this area are reported in
[6] and [3].
Next: GAML
Up: Literature on Threads in
Previous: Threads in SML
Ananda Amatya
2/16/1999