English

Continuation-Passing C: compiling threads to events through continuations

Programming Languages 2012-11-15 v3

Abstract

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 compilation technique for functional languages, is also correct in an imperative language like C, under some conditions enforced by the CPC compiler. The current CPC compiler is mature enough to write substantial programs such as Hekate, a highly concurrent BitTorrent seeder. Our benchmark results show that CPC is as efficient, while using significantly less space, as the most efficient thread libraries available.

Keywords

Cite

@article{arxiv.1011.4558,
  title  = {Continuation-Passing C: compiling threads to events through continuations},
  author = {Gabriel Kerneis and Juliusz Chroboczek},
  journal= {arXiv preprint arXiv:1011.4558},
  year   = {2012}
}

Comments

Higher-Order and Symbolic Computation (2012). arXiv admin note: substantial text overlap with arXiv:1202.3247

R2 v1 2026-06-21T16:46:33.246Z