Threads2Events: An Automatic Code Generation Approach

Alexander Bernauer, Kay Römer, Silvia Santini, Junyan Ma. Threads2Events: An Automatic Code Generation Approach. In Proceedings of the 6th Workshop on Hot Topics in Embedded Networked Sensors (HotEMNETS 2010). Killarney, Ireland, jun 2010.

Abstract

There is a long-standing dispute on whether and when thread-based programming should be preferred over the event-based paradigm. This dispute has also extended into the wireless sensor networks domain. Many existing operating systems rely on events due to their efficiency, but make code management difficult. Others rely on threads for developer comfort, but at the cost of reduced runtime efficiency. In this paper we try to combine the best of both worlds by offering a full-fledged cooperative thread abstraction with blocking I/O to the C programmer that is compiled into efficient event-based code. We present the basic code transformations and investigate their efficiency using a representative application case study. We find that RAM usage of generated code competes with hand-written code, but further optimizations are required to reduce the code size and the number of CPU cycles.