Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/1182807.1182811acmconferencesArticle/Chapter ViewAbstractPublication PagessensysConference Proceedingsconference-collections
Article

Protothreads: simplifying event-driven programming of memory-constrained embedded systems

Published: 31 October 2006 Publication History

Abstract

Event-driven programming is a popular model for writing programs for tiny embedded systems and sensor network nodes. While event-driven programming can keep the memory overhead down, it enforces a state machine programming style which makes many programs difficult to write, maintain, and debug. We present a novel programming abstraction called protothreads that makes it possible to write event-driven programs in a thread-like style, with a memory overhead of only two bytes per protothread. We show that protothreads significantly reduce the complexity of a number of widely used programs previously written with event-driven state machines. For the examined programs the majority of the state machines could be entirely removed. In the other cases the number of states and transitions was drastically decreased. With protothreads the number of lines of code was reduced by one third. The execution time overhead of protothreads is on the order of a few processor cycles.

References

[1]
T. Abdelzaher, J. Stankovic, S. Son, B. Blum, T. He, A. Wood, and C. Lu. A communication architecture and programming abstractions for real-time embedded sensor networks. In Workshop on Data Distribution for Real-Time Systems, Providence, RI, USA, May 2003.]]
[2]
H. Abrach, S. Bhatti, J. Carlson, H. Dai, J. Rose, A. Sheth, B. Shucker, J. Deng, and R. Han. Mantis: system support for multimodal networks of insitu sensors. In Proceedings of the 2nd ACM international conference on Wireless sensor networks and applications, pages 50--59, 2003.]]
[3]
A. Adya, J. Howell, M. Theimer, W.J. Bolosky, and J.R. Douceur. Cooperative Task Management Without Manual Stack Management. In Proceedings of the USENIX Annual Technical Conference, 2002.]]
[4]
E. Cheong, J. Liebman, J. Liu, and F. Zhao. TinyGALS: A programming model for event-driven embedded systems. In Proc. of the 18th Annual ACM Symposium on Applied Computing (SAC'03), Melbourne, Florida, USA, March 2003.]]
[5]
R. Cunningham and E. Kohler. Making events less slippery with eel. In Proceedings of the 10th Workshop on Hot Topics in Operating Systems (HotOS-X), Santa Fee, New Mexico, June 2005. IEEE Computer Society.]]
[6]
F. Dabek, N. Zeldovich, F. Kaashoek, D. Mazières, and R. Morris. Event-driven programming for robust software. In Proceedings of the 2002 SIGOPS European Workshop, Saint-Emilion, France, September 2002.]]
[7]
A.L. de Moura and R. Ierusalimschy. Revisiting coroutines. MCC 15/04, PUC-Rio, Rio de Janeiro, RJ, June 2004.]]
[8]
T. Duff. Unwinding loops. Usenet news article, net.lang.c, MessageID: <[email protected]>, May 1984.]]
[9]
A. Dunkels. Protothreads web site. Web page. Visited 2006-04-06. http://www.sics.se/~adam/pt/]]
[10]
A. Dunkels. Full TCP/IP for 8-bit architectures. In Proceedings of The First International Conference on Mobile Systems, Applications, and Services (MobiSys `03), May 2003.]]
[11]
A. Dunkels, N. Finne, J. Eriksson, and T. Voigt. Run-time dynamic linking for reprogramming wireless sensor networks. In Proceedings of the 4th International Conference on Embedded Networked Sensor Systems, SenSys 2006, Boulder, Colorado, USA, 2006.A. Dunkels, N. Finne, J. Eriksson, and T. Voigt. Run-time dynamic linking for reprogramming wireless sensor networks. In Proceedings of the 4th International Conference on Embedded Networked Sensor Systems, SenSys 2006, Boulder, Colorado, USA, 2006.]]
[12]
A. Dunkels, B. Grönvall, and T. Voigt. Contiki - a lightweight and flexible operating system for tiny networked sensors. In Proceedings of the First IEEE Workshop on Embedded Networked Sensors, Tampa, Florida, USA, November 2004.]]
[13]
A. Dunkels, O. Schmidt, and T. Voigt. Using protothreads for sensor node programming. In Proc. of the Workshop on Real-World Wireless Sensor Networks (REALWSN'05), Stockholm, Sweden, June 2005.]]
[14]
J. Ganssle. The embedded muse. Monthly newsletter. http://www.ganssle.com/tem-back.htm]]
[15]
D. Gay, P. Levis, R. von Behren, M. Welsh, E. Brewer, and D. Culler. The nesC language: A holistic approach to networked embedded systems. In Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and implementation, pages 1--11, 2003.]]
[16]
R. Gummadi, O. Gnawali, and R. Govindan. Macro-programming wireless sensor networks using kairos. In Proc. of Distributed Computing in Sensor Systems (DCOSS)'05, Marina del Rey, CA, USA, June 2005.]]
[17]
C. Han, R.K. Rengaswamy, R. Shea, E. Kohler, and M. Srivastava. Sos: A dynamic operating system for sensor networks. In MobiSys '05: Proceedings of the 3rd international conference on Mobile systems, applications, and services, 2005.]]
[18]
D. Harel. Statecharts: A visual formalism for complex systems. Sci. Comput. Program., 8(3):231--274, 1987.]]
[19]
J. Hill, R. Szewczyk, A. Woo, S. Hollar, D. Culler, and K. Pister. System architecture directions for networked sensors. In Proceedings of the 9th International Conference on Architectural Support for Programming Languages and Operating Systems, November 2000.]]
[20]
J. Jeong. Analysis of xnp network reprogramming module. Web page, October 2003. Visited 2006-04-06. http://www.cs.berkeley.edu/~jaein/cs294 1/xnp anal.htm]]
[21]
O. Kasten and K. Römer. Beyond event handlers: Programming wireless sensors with attributed state machines. In The Fourth International Conference on Information Processing in Sensor Networks (IPSN), Los Angeles, USA, April 2005.]]
[22]
D.E. Knuth. The art of computer programming, volume 1: fundamental algorithms (2nd edition). Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1978.]]
[23]
Framework Labs. Protothreads for Objective-C/Cocoa. Visited 2006-04-06. http://www.frameworklabs.de/protothreads.html]]
[24]
H.C. Lauer and R.M. Needham. On the duality of operating systems structures. In Proc. Second International Symposium on Operating Systems, October 1978.]]
[25]
P. Levis and D. Culler. Mate: A tiny virtual machine for sensor networks. In Proceedings of ASPLOS-X, San Jose, CA, USA, October 2002.]]
[26]
P. Levis, S. Madden, D. Gay, J. Polastre, R. Szewczyk, A. Woo, E. Brewer, and D. Culler. The Emergence of Networking Abstractions and Techniques in TinyOS. In Proc. NSDI'04, March 2004.]]
[27]
S.R. Madden, M.J. Franklin, J.M. Hellerstein, and W. Hong. Tinydb: an acquisitional query processing system for sensor networks. ACM Trans. Database Syst., 30(1):122--173, 2005.]]
[28]
M. Melkonian. Get by Without an RTOS. Embedded Systems Programming, 13(10), September 2000.]]
[29]
R. Newton, Arvind, and M. Welsh. Building up to macroprogramming: An intermediate language for sensor networks. In Proc. IPSN'05, Los Angeles, CA, USA, April 2005.]]
[30]
J. Paisley and J. Sventek. Real-time detection of grid bulk transfer traffic. In Proceedings of the 10th IEEE/IFIP Network Operations Management Symposium, 2006.]]
[31]
J.C. Reynolds. The discoveries of continuations. Lisp Symbol. Comput., 6(3):233--247, 1993.]]
[32]
Z.B. Simpson. State machines: Cooperative mini-kernels with yielding. In Computer Game Developer's Conference, Austin, TX, November 1999.]]
[33]
S. Tatham. Coroutines in C. Web page, 2000. http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html]]
[34]
T. van Dam and K. Langendoen. An adaptive energy-efficient MAC protocol for wireless sensor networks. In Proceedings of the first international conference on Embedded networked sensor systems, pages 171--180, 2003.]]
[35]
R. von Behren, J. Condit, and E. Brewer. Why events are a bad idea (for high-concurrency servers). In Proceedings of the 9th Workshop on Hot Topics in Operating Systems, May 2003.]]
[36]
R. von Behren, J. Condit, F. Zhou, G.C. Necula, and E. Brewer. Capriccio: scalable threads for internet services. In Proc. SOSP '03, pages 268--281, 2003.]]
[37]
M. Welsh and G. Mainland. Programming sensor networks using abstract regions. In Proc. USENIX/ACM NSDI'04, San Francisco, CA, March 2004.]]

Cited By

View all
  • (2024)Unified Processing of Events and Co-routines in Embedded ProgramProgramming and Computer Software10.1134/S036176882470015450:5(343-355)Online publication date: 26-Sep-2024
  • (2024)Secure On-The-Fly Firmware Updates for Safety Critical Embedded Systems2024 IEEE 29th International Conference on Emerging Technologies and Factory Automation (ETFA)10.1109/ETFA61755.2024.10711047(1-7)Online publication date: 10-Sep-2024
  • (2023)A Distributed Algorithmic Approach for Simultaneous Localization and Mapping With Acoustic SensorsProceedings of the 2023 6th International Conference on Advances in Robotics10.1145/3610419.3610446(1-6)Online publication date: 5-Jul-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
SenSys '06: Proceedings of the 4th international conference on Embedded networked sensor systems
October 2006
444 pages
ISBN:1595933433
DOI:10.1145/1182807
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 31 October 2006

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. embedded systems
  2. threads
  3. wireless sensor networks

Qualifiers

  • Article

Conference

SenSys06: ACM Conference on Embedded Network Sensor Systems
October 31 - November 3, 2006
Colorado, Boulder, USA

Acceptance Rates

Overall Acceptance Rate 174 of 867 submissions, 20%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)78
  • Downloads (Last 6 weeks)10
Reflects downloads up to 10 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Unified Processing of Events and Co-routines in Embedded ProgramProgramming and Computer Software10.1134/S036176882470015450:5(343-355)Online publication date: 26-Sep-2024
  • (2024)Secure On-The-Fly Firmware Updates for Safety Critical Embedded Systems2024 IEEE 29th International Conference on Emerging Technologies and Factory Automation (ETFA)10.1109/ETFA61755.2024.10711047(1-7)Online publication date: 10-Sep-2024
  • (2023)A Distributed Algorithmic Approach for Simultaneous Localization and Mapping With Acoustic SensorsProceedings of the 2023 6th International Conference on Advances in Robotics10.1145/3610419.3610446(1-6)Online publication date: 5-Jul-2023
  • (2023)Formal Specification, Verification and Repair of Contiki’s SchedulerACM Transactions on Cyber-Physical Systems10.1145/36059487:4(1-28)Online publication date: 14-Oct-2023
  • (2023)Bringing Segmented Stacks to Embedded SystemsProceedings of the 24th International Workshop on Mobile Computing Systems and Applications10.1145/3572864.3580344(117-123)Online publication date: 22-Feb-2023
  • (2023)StateOS: A Memory-Efficient Hybrid Operating System for IoT DevicesIEEE Internet of Things Journal10.1109/JIOT.2023.323410610:11(9523-9533)Online publication date: 1-Jun-2023
  • (2023)Models of Embedded SystemsEmbedded and Real-Time Operating Systems10.1007/978-3-031-28701-5_4(99-114)Online publication date: 15-Sep-2023
  • (2022)An Architecture and Reference Implementation for WSN-Based IoT SystemsEmerging Trends in IoT and Integration with Data Science, Cloud Computing, and Big Data Analytics10.4018/978-1-7998-4186-9.ch005(80-103)Online publication date: 2022
  • (2022)TempMesh – A Flexible Wireless Sensor Network for Monitoring River TemperaturesACM Transactions on Sensor Networks10.1145/354269719:1(1-28)Online publication date: 8-Dec-2022
  • (2022)Threat-modeling-guided Trust-based Task Offloading for Resource-constrained Internet of ThingsACM Transactions on Sensor Networks10.1145/351042418:2(1-41)Online publication date: 4-Feb-2022
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media