Tasks: language support for event-driven programming

The event-driven programming style is pervasive as an efficient method for interacting with the environment. Unfortunately, the event-driven style severely complicates program maintenance and understanding, as it requires each logical flow of control to be fragmented across multiple independent callbacks. We propose tasks as a new programming model for organizing event-driven programs. Tasks are a variant of cooperative multi-threading and allow each logical control flow to be modularized in the traditional manner, including usage of standard control mechanisms like procedures and exceptions. At the same time, by using method annotations, task-based programs can be automatically and modularly translated into efficient event-based code, using a form of continuation passing style (CPS) translation. A linkable scheduler architecture permits tasks to be used in many different contexts. We have instantiated our model as a backward-compatible extension to Java, called TaskJava. We illustrate the benefits of our language through a formalization in an extension to Featherweight Java, and through a case study based on an open-source web server.

[1]  Eric A. Brewer,et al.  USENIX Association Proceedings of HotOS IX : The 9 th Workshop on Hot Topics in Operating Systems , 2003 .

[2]  Willy Zwaenepoel,et al.  Flash: An efficient and portable Web server , 1999, USENIX Annual Technical Conference, General Track.

[3]  David E. Culler,et al.  The nesC language: A holistic approach to networked embedded systems , 2003, PLDI.

[4]  Marvin Theimer,et al.  Cooperative Task Management Without Manual Stack Management , 2002, USENIX Annual Technical Conference, General Track.

[5]  Christian Queinnec Inverting back the inversion of control or, continuations versus page-centric programming , 2003, SIGP.

[6]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[7]  Ralf S. Engelschall Portable Multithreading-The Signal Stack Trick for User-Space Thread Creation , 2000, USENIX Annual Technical Conference, General Track.

[8]  Matthias Felleisen,et al.  Programming the Web with High-Level Programming Languages , 2001, ESOP.

[9]  John H. Reppy,et al.  CML: A higher concurrent language , 1991, PLDI '91.

[10]  David E. Culler,et al.  System architecture directions for networked sensors , 2000, SIGP.

[11]  Michael R. Clarkson,et al.  Polyglot: An Extensible Compiler Framework for Java , 2003, CC.

[12]  Joe Marshall,et al.  Continuations from generalized stack inspection , 2005, ICFP '05.

[13]  Mitchell Wand,et al.  Trampolined style , 1999, ICFP '99.

[14]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 1999, OOPSLA '99.

[15]  Todd Millstein,et al.  Preventing lost messages in event-driven programming , 2006 .

[16]  George C. Necula,et al.  Capriccio: scalable threads for internet services , 2003, SOSP '03.

[17]  David E. Culler,et al.  SEDA: an architecture for well-conditioned, scalable internet services , 2001, SOSP.

[18]  M. Felleisen,et al.  Automatically restructuring programs for the Web , 2001, Proceedings 16th Annual International Conference on Automated Software Engineering (ASE 2001).

[19]  Peng Li,et al.  Advanced control flow in Java card programming , 2004, LCTES '04.