Compiling threads to events through continuations
نویسندگان
چکیده
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.
منابع مشابه
Continuation-Passing C, compiling threads to events through continuations
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 th...
متن کاملLambda-lifting and CPS conversion in an imperative language
This paper is a companion technical report to the article “Continuation-Passing C: from threads to events through continuations”. It contains the complete version of the proofs of correctness of lambda-lifting and CPS-conversion presented in the article.
متن کاملContinuations: Multiple Invocations Considered Harmful
In this paper, we propose to replace Scheme rst class continuations by a sequential thread system. Our threads are very close to continuations but they are easier to understand and to use for programmers, and its implementation is simpler and more eecient. We show that with our threads we can recover almost completely the Scheme operator call-with-current-continuation (call/cc for short). The o...
متن کاملCompiling Dataaow into Threads Eecient Compiler-controlled Multithreading for Lenient Parallel Languages Compiling Dataaow into Threads Eecient Compiler-controlled Multithreading for Lenient Parallel Languages Compiling Dataaow into Threads Eecient Compiler-controlled Multithreading for Lenient Parallel Languages
Powerful non-strict parallel languages require fast dynamic scheduling. This thesis explores how the need for multithreaded execution can be addressed as a compilation problem, to achieve switching rates approaching what hardware mechanisms might provide. Compiler-controlled multithreading is examined through compilation of a lenient parallel language, ID90, for a threaded abstract machine, TAM...
متن کاملCompiling ATL with Continuations
This paper presents a proposal to use continuations as an implementation mechanism for ATL. We introduce the notion of continuation, showing its applicability to model-to-model transformations, and develop a simple mechanism to enable continuations in model transformations. Then, the declarative part of ATL is mapped to this mechanism.
متن کامل