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).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Arm ltd. The ARM-THUMB Procedure Call Standard - A-05. ARM Limited (1998)
Arm ltd, ARM Ltd. Homepage (2010), http://www.arm.com
Arm ltd, Procedure Call Standard for the ARM Architecture. ARM Limited (2008)
Arm ltd, RealView Compilation Tools Version 4.0 Essentials Guide. ARM Limited (2008)
Behren, R.V., Condit, J., Zhou, F., et al.: Capriccio: Scalable Threads for Internet Services. ACM SIGOPS Operating Systems Review 37, 268–281 (2003)
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)
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)
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)
Chatterjee, K., Ma, D., Majumdar, R., et al.: Stack size analysis for interrupt-driven programs. Information and Computation 194, 144–174 (2004)
Dunkels, A.: The uIP Embedded TCP/IP Stack. (2006), http://www.sics.se/~adam/uip
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)
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)
Free software foundation, GNU ARM toolchain 4.3.2 (2010), http://www.gnuarm.org/home.html
Guillemin, P.: ST Application Note, Stack overflow detection using the ST9 watchdog timer. SGS-THOMSON Microelectronics Group of Companies (1994)
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)
Hill, J., Szewczyk, R., Woo, A., et al.: System architecture directions for networked sensors. ACM SIGPLAN Notices 35, 93–104 (2000)
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)
Kim, H., Cha, H.: Multithreading Optimization Techniques for Sensor Network Operating Systems. Lecture Notes In Computer Science 4373, 293–308 (2007)
Ousterhout, J.: Why Threads Are A Bad Idea (for most purposes). In: Usenix Annual Technical Conference, San Diego, California, USA (1996)
Park, S.H.: Ubinos - A Multi-threaded Operating System for Resource-limited Embedded Systems (2010), http://www.ubinos.org
Park, S.H.: Ubitools - The Develpment Tools for the Ubinos (2010), http://www.ubinos.org/mediawiki/index.php/Ubitools
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,
Real time engineers ltd, FreeRTOS - A FREE open source RTOS for small embedded real time systems (2010), http://www.freertos.org
Regehr, J.: Say no to stack overflow. Embedded Systems Programming 17, 10–20 (2004)
Regehr, J., Reid, A., Webb, K.: Eliminating Stack Overflow by Abstract Interpretation. ACM Transactions on Embedded Computing Systems 4, 751–778 (2005)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)