CPC:使用大量轻量级线程进行编程
CPC: programming with a massive number of lightweight threads
摘要:
线程是编写并发程序的一种方便和模块化的抽象,但通常相当昂贵。线程的标准替代方案,事件循环编程,允许更轻的并发单元,但导致代码难以编写,甚至更难理解。Continuation Passing C(CPC)是一个翻译器,可根据程序员的选择,将以线程风格编写的程序转换为使用事件和本机系统线程编写的程序。我们与两名本科生一起,通过编写Hekate自学了如何在CPC中编程,Hekate是一个大规模并发网络服务器,旨在有效地处理成千上万的同时连接的对等体。在本文中,我们描述了一些编程习惯用法,我们在写Hekate时学到的;虽然其中一些习惯用法是特定于CPC的,但许多应该适用于其他具有足够便宜的线程的编程系统。
英文摘要:
Threads are a convenient and modular abstraction for writing concurrent programs, but often fairly expensive. The standard alternative to threads, event-loop programming, allows much lighter units of concurrency, but leads to code that is difficult to write and even harder to understand. Continuation Passing C (CPC) is a translator that converts a program written in threaded style into a program written with events and native system threads, at the programmer's choice. Together with two undergraduate students, we taught ourselves how to program in CPC by writing Hekate, a massively concurrent network server designed to efficiently handle tens of thousands of simultaneously connected peers. In this paper, we describe a number of programming idioms that we learnt while writing Hekate; while some of these idioms are specific to CPC, many should be applicable to other programming systems with sufficiently cheap threads.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。