Continuation-Passing C, compiling threads to events through continuations

  title={Continuation-Passing C, compiling threads to events through continuations},
  author={Gabriel Kerneis and Juliusz Chroboczek},
  journal={Higher-Order and Symbolic Computation},
In this paper, we introduce Continuation Passing C (CPC), a programming language for concurrent systems in which native and cooperative threads are unified and presented to the programmer as a single abstraction. The CPC compiler uses a compilation technique, based on the CPS transform, that yields efficient code and an extremely lightweight representation for contexts. We provide a proof of the correctness of our compilation scheme. We show in particular that lambda-lifting, a common… 

Continuation-Passing C: Program Transformations for Compiling Concurrency in an Imperative Language. (Continuation-Passing C : Transformations de programmes pour compiler la concurrence dans un langage impératif)

This dissertation shows that concurrent programs written in threaded style can be translated automatically into efficient, equivalent event-driven programs through a series of proven source-to-source transformations, in particular lambda lifting and CPS conversion, for an imperative language.

CPC: programming with a massive number of lightweight threads

A number of programming idioms that the authors learnt while writing Hekate are described; while some of these idioms are specific to CPC, many should be applicable to other programming systems with sufficiently cheap threads.

Generating events with style

It is observed that it is possible to generate any of these styles automatically from threaded code, by applying certain carefully chosen classical program transformations, and two of these transformations are implemented, lambda lifting and environments, in CPC, an extension of the C language for writing concurrent systems.

QEMU/CPC: static analysis and CPS conversion for safe, portable, and efficient coroutines

This work proposes a new type of annotations to identify functions which never cooperate, and introduces CoroCheck, a tool for the static analysis and inference of cooperation annotations, and improves the CPC translator, which is applied to QEMU, an open-source machine emulator which also uses annotated coroutine functions for concurrency.

Scaling Sequential Code with Hardware–Software Co-Design for Fine-Grain Speculative Parallelization

SCC introduces novel compiler techniques to exploit Swarm’s features and parallelize a broader range of applications than prior work, and speeds up seven SPEC CPU2006 benchmarks by gmean 6.7× and by up to 29× on 36 cores, over optimized serial code.

Efficiency and expressiveness in UW-OpenMP

A source to source transformation scheme to translate UWOmp++ C programs to equivalent OpenMP C programs that are guaranteed not to invoke barriers in any task, and implements the proposed translation scheme in the ROSE compiler framework.

Asynchronous Programming in a Prioritized Form

A new and simple, yet powerful, model for asynchronous programming that consists of a context-free grammar and an operational semantics, supported by the ability to express important applications.

Control flow obfuscation via CPS transformation

This work proposes a new control flow obfuscation technique by rewriting the source program in the continuation passing style (CPS), where the continuation is encoded through higher order combinators and function pointers at the target language level.

Proceedings 7th Workshop on Programming Language Approaches to Concurrency and Communication-cEntric Software (PLACES'14)

This volume contains the post-proceedings of PLACES 2014, the seventh Workshop on Programming Language Approaches to Concurrency and Communication-cEntric Software, which was held in Grenoble,

Alpaca: intermittent execution without checkpoints

Alpaca is introduced, a low-overhead programming model for intermittent computing on energy-harvesting devices that provides a familiar programming interface, a highly efficient runtime model, and places fewer restrictions on a target device's hardware architecture.



Continuation-passing for C: a space-efficient implementation of concurrency

Continuation Passing C is a concurrent extension of C with very cheap threads implemented as a series of source-tosource transformations, including CPS conversion, that convert a threaded program in direct style into a purely sequential C program.

CPC: programming with a massive number of lightweight threads

A number of programming idioms that the authors learnt while writing Hekate are described; while some of these idioms are specific to CPC, many should be applicable to other programming systems with sufficiently cheap threads.

Compiling with Continuations

This book shows how continuation-passing style is used as an intermediate representation to perform optimizations and program transformations to create practical optimizing compilers for modern languages like ML.

Rabbit: A Compiler for Scheme

A compiler for the lexically-scoped dialect of LISP known as SCHEME, which handles only a small basis set which reflects the semantics of lambda-calculus, and serves to produce code as good as that produced by more traditional compilers.

A concurrency monad based on constructor primitives: or, being first-class is not enough

The paper argues that this technique helps to remedy a recurrent dilemma in the design of concurrent programming languages, namely, how to keep the language small, coherent, and rigorously defined, yet to provide the programmer with all the communication constructs required.

Lwt: a cooperative thread library

A cooperative thread library for Objective Caml is presented, which makes it possible to write threaded code almost as regular ML code, even though it has a different semantics.

Scala Actors: Unifying thread-based and event-based programming

AC: composable asynchronous IO for native languages

AC is introduced, a set of language constructs for composable asynchronous IO in native languages such as C/C++ that retains a sequential style of programming without requiring code to use multiple threads, and without require code to be "stack-ripped" into chains of callbacks.

Kilim: Isolation-Typed Actors for Java

Kilim is a framework that employs a combination of techniques to help create robust, massively concurrent systems in mainstream languages such as Java: (i) ultra-lightweight, cooperatively-scheduled threads, (ii) a message-passing framework and (iii) isolation-aware messaging.

Tasks: language support for event-driven programming

Tasks is proposed as a new programming model for organizing event-driven programs that allows each logical control flow to be modularized in the traditional manner, including usage of standard control mechanisms like procedures and exceptions.