Continuation Passing C (CPC)

Home | Research | Software | Teaching | Contact

CPC is a programming language for writing concurrent systems, designed and developped by Juliusz Chroboczek and Gabriel Kerneis.

The CPC programmer manipulates very lightweight threads, choosing whether they should be cooperatively or preemptively scheduled at any given point; the CPC program is then processed by the CPC translator, which produces highly efficient event-loop code. This approach gives the best of both worlds: the relative convenience of programming with threads, and the low memory usage of event-loop code.

The semantics of CPC is defined as a source-to-source translation from CPC into plain C using a technique known as conversion into Continuation Passing Style.

The current implementation of CPC has been used to write Hekate, a BitTorrent seeder designed to handle millions of simultaneous torrents and tens of thousands of simultaneously connected peers.

Reading

Gabriel Kerneis, Charlie Shepherd, Stefan Hajnoczi. QEMU/CPC: Static Analysis and CPS Conversion for Safe, Portable, and Efficient Coroutines. PEPM'14, San Diego, CA, USA, January 20-21, 2014.
Also available in html and epub format.

Gabriel Kerneis. Continuation-Passing C: Program Transformation for Compiling Concurrency in an Imperative Language. PhD thesis. Laboratoire PPS, Université Paris Diderot (2012).

Gabriel Kerneis, Juliusz Chroboczek. Continuation-Passing C, compiling threads to events through continuations. Higher-Order and Symbolic Computation 24(3): 239-279 (2011). doi:10.1007/s10990-012-9084-5.

Gabriel Kerneis, Juliusz Chroboczek. CPC: programming with a massive number of lightweight threads. PLACES'11 (2011). hal-00563369.

Matthieu Boutier, Gabriel Kerneis. Generating events with style. Unpublished draft (2012). arXiv:1210.4263

Gabriel Kerneis, Juliusz Chroboczek. Are events fast?. Technical report, Université Paris Diderot (2009). hal-00434374.
Experimental setup: how to benchmark a web server.

Juliusz Chroboczek. Continuation Passing for C: A space-efficient implementation of concurrency. PPS technical report (2005).

Juliusz Chroboczek, Gabriel Kerneis. The CPC manual. Release 0.1 (2010).

Download

CPC 0.9.1 is available: cpc-0.9.1.tar.gz (PGP signature)

In order to download and build the latest version of the CPC translator:

  • git clone git://git.wifi.pps.univ-paris-diderot.fr/cpc
  • cd cpc
  • ./configure
  • make
  • make testcpc

Bug reports

Please report bugs on the CPC bug tracker on Github.

  • git clone git://github.com/kerneis/cpc

Back to my software page