摘要: 针对嵌入式系统开发中多线程技术可移植性较差的问题,提出一种通用的轻量级多线程模型——lwThread,采用标准C语言实现,在源程序级实现线程的切换。与同类技术相比,lwThread不但可以实现线程的优先级,还可以为每个线程动态分配独立的栈空间,同时介绍确定共享栈池大小的理论依据。实验结果表明,lwThread模型可以有效提高开发效率,并降低资源消耗。
关键词:
通用多线程,
共享栈,
嵌入式系统,
计算机体系结构
Abstract: Aiming at the lack of portability problem of multithreading technology in embedded system development, a lightweight general multithreading model called lwThread is proposed, which is developed in pure C language. The threads context switch in standard C statement is implemented. Compared with other thread models, lwThread combines the priority scheduling with dynamic stack allocation in shared-stack pool. This paper also presents a method to determine the maximum stack usage in the shared stack. Experimental results show this lwThread model can improve the efficiency of development and reduce consumption of resources.
Key words:
general multithreading,
shared stack,
embedded system,
computer architecture
中图分类号:
杜 敏;章 莉;朱 琨;吴百锋. lwThread:轻量级通用多线程[J]. 计算机工程, 2009, 35(11): 43-45.
DU Min; ZHANG Li; ZHU Kun; WU Bai-feng. lwThread: Lightweight General Multithreading[J]. Computer Engineering, 2009, 35(11): 43-45.