Skip to main content

Compiler-Assisted Maximum Stack Usage Measurement Technique for Efficient Multi-threading in Memory-Limited Embedded Systems

  • Conference paper

Part of the book series: Studies in Computational Intelligence ((SCI,volume 365))

Summary

One of the reasons why it is hard to use multi-threading in memory-limited embedded systems is the difficulty of stack optimization. Some solutions for this problem have been proposed in prior research, but the proposed solutions were not totally effective. This paper proposes the compiler-assisted maximum stack usage measurement technique as a new solution for this problem. This technique measures the maximum stack usage of each thread with special code that is automatically inserted at the beginning of each function by the compiler. With the help of the operating system, the special code records the maximum stack usage of each thread in run-time. Also, the special code predicts and prevents stack overflow in run-time. Therefore, with this technique, the maximum stack usage of each thread can be precisely determined during testing, and thus allowing the stack of each thread to be accurately optimized. Unlike the solutions proposed in previous research, this technique does not have problems such as limited availability, the possibility of undetectable stack usage, and memory fragmentation. Although this technique adds some overhead, the overhead is added only during the stack optimization process in the development phase. Also, despite the necessity for modification of the compiler and operating system, this technique is easy to implement. It can be implemented by slight modification of the existing compiler and operating system. To verify this technique, it was implemented and evaluated on the ARM platform by modifying the GNU ARM C compiler and the Ubinos, which is an operating system for memory-limited embedded systems.

This research was supported by Basic Science Research Program through the National Research Foundation of Korea(NRF) funded by the Ministry of Education, Science and Technology(2010-0003387).

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   129.00
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   169.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD   169.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Arm ltd. The ARM-THUMB Procedure Call Standard - A-05. ARM Limited (1998)

    Google Scholar 

  2. Arm ltd, ARM Ltd. Homepage (2010), http://www.arm.com

  3. Arm ltd, Procedure Call Standard for the ARM Architecture. ARM Limited (2008)

    Google Scholar 

  4. Arm ltd, RealView Compilation Tools Version 4.0 Essentials Guide. ARM Limited (2008)

    Google Scholar 

  5. Behren, R.V., Condit, J., Zhou, F., et al.: Capriccio: Scalable Threads for Internet Services. ACM SIGOPS Operating Systems Review 37, 268–281 (2003)

    Article  Google Scholar 

  6. Bhatti, S., Carlson, J., Dai, H., et al.: MANTIS OS: An Embedded Multithreaded Operating System for Wireless Micro Sensor Platforms. Mobile Networks and Applications 10, 563–579 (2005)

    Article  Google Scholar 

  7. Biswas, S., Carley, T., Simpson, M., et al.: Memory Overflow Protection for Embedded Systems using Run-time Checks, Reuse, and Compression. ACM Transactions in Embedded Computing Systems 5, 719–752 (2006)

    Article  Google Scholar 

  8. Brylow, D., Damgaard, N., Palsberg, J.: Static Checking of Interrupt-driven Software. In: Proceedings of the 23rd International Conference on Software Engineering, pp. 47–56. IEEE Computer Society Press, Toronto (2001)

    Google Scholar 

  9. Chatterjee, K., Ma, D., Majumdar, R., et al.: Stack size analysis for interrupt-driven programs. Information and Computation 194, 144–174 (2004)

    Article  MATH  MathSciNet  Google Scholar 

  10. Dunkels, A.: The uIP Embedded TCP/IP Stack. (2006), http://www.sics.se/~adam/uip

  11. Dunkels, A., Gronvall, B., Voigt, T.: Contiki - A Lightweight and Flexible Operating System for Tiny Networked Sensors. In: Proceedings of the 29th Annual IEEE International Conference on Local Computer Networks, pp. 455–462. IEEE Computer Society Press, Tampa (2004)

    Chapter  Google Scholar 

  12. Dunkels, A., Schmidt, O., Voigt, T., et al.: Protothreads: Simplifying Event-driven Programming of Memory-constrained Embedded Systems. In: Proceedings of the 4th international conference on Embedded networked sensor systems, ACM, Boulder (2006)

    Google Scholar 

  13. Free software foundation, GNU ARM toolchain 4.3.2 (2010), http://www.gnuarm.org/home.html

  14. Guillemin, P.: ST Application Note, Stack overflow detection using the ST9 watchdog timer. SGS-THOMSON Microelectronics Group of Companies (1994)

    Google Scholar 

  15. Han, C.-C., Kumar, R., Shea, R., et al.: A Dynamic Operating System for Sensor Nodes. In: Proceedings of the 3rd international conference on Mobile systems, applications, and services, pp. 163–176. ACM, Seattle (2005)

    Chapter  Google Scholar 

  16. Hill, J., Szewczyk, R., Woo, A., et al.: System architecture directions for networked sensors. ACM SIGPLAN Notices 35, 93–104 (2000)

    Article  Google Scholar 

  17. Kasten, O., Romer, K.: Beyond Event Handlers: Programming Wireless Sensors with Attributed State Machines. In: Proceedings of the 4th international symposium on Information processing in sensor networks, pp. 45–52. IEEE Press, Los Alamitos (2005)

    Google Scholar 

  18. Kim, H., Cha, H.: Multithreading Optimization Techniques for Sensor Network Operating Systems. Lecture Notes In Computer Science 4373, 293–308 (2007)

    Article  Google Scholar 

  19. Ousterhout, J.: Why Threads Are A Bad Idea (for most purposes). In: Usenix Annual Technical Conference, San Diego, California, USA (1996)

    Google Scholar 

  20. Park, S.H.: Ubinos - A Multi-threaded Operating System for Resource-limited Embedded Systems (2010), http://www.ubinos.org

  21. Park, S.H.: Ubitools - The Develpment Tools for the Ubinos (2010), http://www.ubinos.org/mediawiki/index.php/Ubitools

  22. Ralf, S.E.: Portable multithreading: the signal stack trick for user-space thread creation. In: Proceedings of the annual conference on USENIX Annual Technical Conference. USENIX Association, San Diego, California, USA,

    Google Scholar 

  23. Real time engineers ltd, FreeRTOS - A FREE open source RTOS for small embedded real time systems (2010), http://www.freertos.org

  24. Regehr, J.: Say no to stack overflow. Embedded Systems Programming 17, 10–20 (2004)

    Google Scholar 

  25. Regehr, J., Reid, A., Webb, K.: Eliminating Stack Overflow by Abstract Interpretation. ACM Transactions on Embedded Computing Systems 4, 751–778 (2005)

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Park, S.H., Lee, D.K., Kang, S.J. (2011). Compiler-Assisted Maximum Stack Usage Measurement Technique for Efficient Multi-threading in Memory-Limited Embedded Systems. In: Lee, R. (eds) Computers,Networks, Systems, and Industrial Engineering 2011. Studies in Computational Intelligence, vol 365. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-21375-5_10

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-21375-5_10

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-21374-8

  • Online ISBN: 978-3-642-21375-5

  • eBook Packages: EngineeringEngineering (R0)

Publish with us

Policies and ethics