Continuation-Passing C: compiling threads to events through continuations
Gabriel Kerneis (PPS), Juliusz Chroboczek (PPS)

TL;DR
This paper presents Continuation Passing C (CPC), a unified approach to concurrent programming in C that compiles threads into efficient event-driven code using CPS transforms, demonstrating correctness and practical efficiency.
Contribution
It introduces CPC, a novel compiler that unifies native and cooperative threads in C, employing CPS transforms and lambda-lifting, with proven correctness and practical implementation.
Findings
CPC achieves efficiency comparable to top thread libraries.
CPC uses less space than existing thread libraries.
Successfully implemented a complex program, Hekate, in CPC.
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
