LISP AND SYMBOLIC COMPUTATION: An International Journal, 10, 223–236, 1997 c 1997 Kluwer Academic Publishers – Manufactured in The Netherlands Threads yield continuations * SANJEEV KUMAR (skumar@cs.princeton.edu ) Department of Computer Science Princeton University Princeton, NJ 08544 USA CARL BRUGGEMAN (bruggema@cse.uta.edu ) Department of Computer Science and Engineering University of Texas at Arlington Arlington, TX 76019-0015 USA R. KENT DYBVIG (dyb@cs.indiana.edu ) Computer Science Department Indiana University Bloomington, IN 47405 USA (Received: ) (Revised: ) Keywords: Concurrency, Continuations, Control delimiters, Control operators, Threads Abstract. Just as a traditional continuation represents the rest of a computation from a given point in the computation, a subcontinuation represents the rest of a subcomputation from a given point in the subcomputation. Subcontinuations are more expressive than traditional continuations and have been shown to be useful for controlling tree-structured concurrency, yet they have previously been implemented only on uniprocessors. This article describes a concurrent implementation of one-shot subcontinuations. Like one- shot continuations, one-shot subcontinuations are first-class but may be invoked at most once, a restriction obeyed by nearly all programs that use continuations. The techniques used to implement one-shot subcontinuations may be applied directly to other one-shot continuation mechanisms and may be generalized to support multi-shot continuations as well. A novel feature of the implementation is that continuations are implemented in terms of threads. Because the implementation model does not rely upon any special language features or compilation techniques, the model is applicable to any language or language implementation that supports a small set of thread primitives. 1. Introduction Continuations have proven useful for implementing a variety of control structures, such as nonlocal exits, exceptions, nonblind backtracking [28], * This material is based on work supported in part by the National Science Foundation under grant numbers CDA-9312614 and CDA 93-03189.