Event Synchronization by Lightweight Message Passing
Concurrent ML’s events and event combinators facilitate modular concurrent programming with first-class synchronization abstractions. A standard implementation of these abstractions relies on fairly complex manipulations of first-class continuations in the underlying language. In this paper, we present a lightweight implementation of these abstractions in Concurrent Haskell, a language that already provides first-order message passing. At the heart of our implementation is a new distributed synchronization protocol. In contrast with several previous translations of event abstractions in concurrent languages, we remain faithful to the standard semantics for events and event combinators; for example, we retain the symmetry of $\mathtt{choose}$ for expressing selective communication.
💡 Research Summary
The paper presents a lightweight implementation of Concurrent ML (CML) style first‑class events and event combinators in Concurrent Haskell, relying solely on first‑order message passing rather than the continuation‑based machinery traditionally used in CML runtimes. The authors introduce a distributed synchronization protocol that models three logical entities: points, channels, and synchronizers. A point represents a pending input or output action on a channel; a channel can be free or busy and mediates the matching of two points; a synchronizer controls which of the competing points is selected for commitment.
These entities are formalized as an abstract state machine (ASM). The machine’s state consists of parallel compositions of sub‑states for points, channels, and synchronizers. Transition rules (I–IV) describe: (I) how two points contacting a free channel become candidates and the channel becomes busy; (II) how each point interacts with its synchronizer, either being selected (if the synchronizer is still open) or rejected (if already closed); (III) how the channel confirms a commit when both points are selected, or cancels the match when only one is selected; (IV) how a confirmed selection triggers the associated action, while a rejected selection causes the synchronizer to reboot with fresh point names.
The paper then defines a compilation from a simplified source language (parallel composition of actions and select constructs) to ASM states. Each channel is initialized as free, and each select expression is compiled into a synchronizer together with a set of fresh points. The authors prove a correctness theorem: the compiled ASM faithfully implements selective communication. The proof establishes three properties—Correspondence (state reductions correspond to program reductions), Safety (no spurious reductions), and Progress (any program that can make a step yields a corresponding ASM step).
Implementation details are given for Concurrent Haskell. The authors use MVar cells (single‑slot mutable variables) and the IO monad. Points are represented by fresh MVars; channels are processes that coordinate two point processes via candidate and match messages; synchronizers are separate processes that receive Select, Reject, and Done messages from points and decide which point proceeds. The Haskell API mirrors the CML interface:
new :: IO (Channel τ)creates a fresh channel.receive :: Channel τ -> Event τandtransmit :: Channel τ -> τ -> Event ()build primitive events.guard :: IO (Event τ) -> Event τandwrap :: Event τ -> (τ -> IO τ') -> Event τ'add pre‑ and post‑synchronization effects.- `choose ::
Comments & Academic Discussion
Loading comments...
Leave a Comment