摘要
嵌入式系统是以应用为中心,以计算机技术为基础,软硬件可剪裁,适应应用系统对功能、可靠性、成本、体积、功耗等综合性严格要求的专用性系统。它一般由嵌入式处理器、相关支撑硬件、嵌入式操作系统及上层应用软件系统组成,用以实现对其它设备的控制、监视和管理等功能。
μc/os-Ⅱ作为一种嵌入式硬实时操作系统,以其良好的可靠性和卓越的实时性被广泛地应用在通信、军事、航空、航天等高精尖技术及实时性要求极高的领域中。μc/os-Ⅱ实际上是一个实时操作系统内核,只包含了任务调度、任务管理、时间管理、内存管理和任务间的通信与同步等基本功能,本文重点分析了其中的任务管理机制。
μc/os-Ⅱ对任务的管理和调度主要是通过任务控制块和任务就绪表来实现的。但由于μc/os-Ⅱ就绪表结构是基于所有任务的优先级都不同这个前提,因此在μc/os-Ⅱ中,任意的两个任务都必须有不同的优先级,即使这两个任务具有同等的重要性,这种设计就导致了μc/os-Ⅱ任务切换不合理、处理优先级反转麻烦等一系列问题。针对这种情况,本文对μc/os-Ⅱ的任务调度进行了改进,将原有的基于就绪表的调度视为对优先级下就绪任务集合的调度,在确定当前优先级最高的就绪任务集合之后,再使用时间片轮转调度进行具体任务的调度。在此基础上,针对实时内核中最易出现的优先级反转问题,通过对μc/os-Ⅱ中与互斥信号量相关的函数的修改,使μc/os-Ⅱ具备了优先级继承的功能,从而消除了优先级反转。
LPC2000系列是基于一个支持实时仿真和跟踪的16/32位ARM7TDMI-STMCPU的微控制器。本文将μc/os-Ⅱ移植到该处理器上,给出了相关移植文件的详细代码,并编写了一个多任务程序,对移植后的系统进行了测试,通过在实验箱上的仿真,表明了移植的正确性。文章最后利用移植后的平台,开发了一个简易的数字示波器系统,进一步了解了基于嵌入式实时操作系统的程序设计技术。
Embedded system is a kind of special system that can meet application system’s compositive and strict demand on function, reliability, cost, size and power consumption. It is based on computer technology, takes applying as centre, based on computer technology, its software and hardware can be reduced. Generally it is composed of microprocessor, relevant supporting hardware, embedded operation system and upper level application software system. Therefore, it realizes control, surveillance and management of other equipments.
μc/os-Ⅱis a embedded real-time operating systems (RTOS) ,with its excellent reliability and real-time performance, it has been widely used in communications, military, aviation, aerospace and other areas with high-technology and high-demand of real-time performance..μc/os-Ⅱis a real-time operating system kernel, only contains task scheduling, task management, time management, memory management and inter-task communication and synchronization, and other basic functions, This paper mainly analyses tasks management and interrupt mechanism.
Task management ofμc/os-Ⅱkernel is realized by task control block and task ready table. The ready table needs different task should have different priority, even if these two tasks are of equal importance. Therefore it leads several problems on task switch and priority inversion. In this situation, this paper make some improvement on task scheduling, it schedules tasks in the set with same priority, instead of in task ready table, it determines the highest-priority tasks set firstly, then schedules tasks in this set with time slice method.The problem of priority revertion is very common in real-tijme kernel, this paper makes some correction on the function concerning about mutex signal, thereby solves this problem.
LPC2000 series is a microcontrollers based on the 16-/32-bit ARM7TDMI-STMCPU that supports real-time simulation and tracking,This paper portsμc/os-Ⅱto this processor, lists detail code, and support a multi-task program, it also test the system after porting, the simulation experiment show the correctness of this porting.Finally to show how to program on embedded real-time operating system, this paper develops a digital oscillograph system.
引文
[1] 杜春雷.ARM 体系结构与编程.清华大学出版社,2003
[2] 黄力.实时操作系统的移植与扩展性研究.现代电子技术,2005.14
[3] 何小庆.嵌入式实时操作系统的现状和未来.单片机与嵌入式系统应用,2001
[4] Jean J.Labrosse. 嵌入式实时操作系统 μc/os-Ⅱ(第二版).邵贝贝等译.北京航空航学,2003.5
[5] 李传煌,王伟明.T-Kernel 任务调度的实时性分析.计算机工程,2006.8.32 (16)
[6] 李仕涌,谭南林.多任务操作系统在嵌入式系统开发中的应用.北方交通大学学报, 2002. 26(4)
[7] 李小平,王海波,王守峰.时间片随机到达的轮转调度算法分析.哈尔滨理工大学学报, 2001. 10.6(5)
[8] 宋寅卯,张青波. μc/os-Ⅱ在 S3C44BOX 上的移植.微计算机信息,2005.21(4)
[9] 田泽.嵌入式系统开发与应用.北京航空航天大学,2005.1
[10] 徐文清,杨红雨.一种基于动态优先级的实时混合任务调度算法.四川大学学报, 2006. 6.43(3)
[11] 王春铭,刘振华,郭去飞.实时操作系统中应用软件设计的任务划分.计算机工程,2000.26(7)
[12] 王原丽.μc/os-Ⅱ中的时钟中断研究.单片机与嵌入式系统设计,2005. 9
[13] 曾鸣. μc/os-Ⅱ实时操作系统在嵌入式平台上进行移植的一般方法和技巧.今日电子, 2004.11
[14] A.Burns,A.Welling. Real-Time System and Programming Languages. Second Edition. Published by Addison-Wesley, 1996
[15] A.Girault,C.Lavarenne,Y.Sorel. Fault-Tolerant Static Scheduling for Real-Time Distributed Embedded Systems. The 21st International Conference on Distributed Computing Systems, 2001
[16] A.N. Audsley, A. Bums and M. Richardson etal. Applying new scheduling theory to static priority pre-emptive scheduling. Software Engineering Journal,1993.(8): 284-292,
[17] Atlas A,Blundon B. Time to Reach for It All. Unix Review, January 1989.
[18] Batel, etal. Real-time embedded system. Computing&Control Engineering journal. 2002. (4): 154~156
[19] Bruno Dutertre,Victoria Stavridou. Formal Analysis for Real-Time Scheduling. Digital Avionics Systems Conferences, 2000.Proceedings. DASC. The Philadelphia. PA. USA, 2000,1
[20] C.M.Krishna,Kang.G.Shin. Rea-Time Systems. Tsinghua University Press, McGraw-Hill,2001
[21] F.Thomas,M.M.Nayak. A Hardware/SoRware Co-design for Improved Data Acquisition in a Processor Based Embedded System. Microprocessor and Microsystems. 2000.(24):129-134
[22] Ganssle Jack G. The art of programming embedded systems. Academic Press,1992
[23] J.A.Stankovic,M.Spuri,M.D.Natale,GC.Butazzo. Implications of Classical Scheduling Results for Real-Time Systems. IEEE Computer, 1995.28(6):16-25
[24] Jae-Ho Lee. Implementing priorit inheritance semaphore on μc/os real-time kernel. Software Technologies for Future Embedded Systems, 2003. IEEE Workshop on, 15-16 May 2003
[25] Jae-Ho Lee,Heung-Nam Kim. Implementing Priority Inheritance Semaphore on μc/os Real-Time Kernel. IEEE, 2003
[26] Jean J.Labrosse. Embedded System Building Blocks. Complete and Ready-to-use Modules in C.UAS R&D Publication. l998
[27] Jejurikar,Ravindra Gupta,Rajesh Energy. Task Scheduling with TaskSynchronization for Embedded Real Time Systems. CASES, 2002.10
[28] John A.Stankovie. Strategic Directions in Real-time and Embedded Systems. ACM Computing Surveys, 1996.28 (4):751-763
[29] John M,Rodrigues Jr. Characteristics of Commercial RTOS. Proceedings of the 2001 International Conference on Embedded System, 2001.10
[30] K.J.Lin. Scheduling model for real-time systems. In Proceedings of 10 IEEE Real-Time Systems Symposium, Dec. 1993: 133-134
[31] L.Sha,B.Sprunt,J.Lehoczky. Aperiodic Task Scheduling for Hard Real-Time System. The Journal of Real-Time System, 1989:27-69
[32] M.Joseph,P.Pandya. Finding response times in a real-time system. BCS Computer Journal, 1986.29(5):390-395
[33] Morgan K. The RTOS Difference. Byte, August 1992.
[34] Nimal Nissanke. Real-time Systems. published by Prentice Hall, 1997
[35] O.Redell,M.Torngren. Calculating exact worst case response times for static priority scheduled tasks with ofsets and jiter. Proceedings of Eighth IEEE Real-Time and Embedded Technology and Applications Symposium, 2002:164-172
[36] P.Gai,GLipari,L.Abeni etal. Architecture for a Portable Open Source Real-Time Kernel Environmet. In Proceedings of the 2nd Real-Time Linux Workshop and Hand's on Real-Time Linux Turorial, 2000.11
[37] P.Gai,G.LiPari,M.D.Natale. Stack size minimization for embedded real-time systems on a chip.In Journal of Design Automation for embedded systems, 2002(7):55-87
[38] Philips 公司. LPC2200 User Manual. Philips 公司, 2004
[39] Porting application software in the embedded system environment. Electronic engineering, 2000:35-41
[40] Pramote Kuacharoen,Tankut Akgul,Vincent J.Moo. Adaptability,Extensibility and Flexibility in Real-Time Operating Systems. Digital Systems.Design, 2001.Proceeding.Euromicro Symposiumon.Warsaw.Poland, 2001:400-405
[41] Robert P,DicK Ganesh Lakshminarayana. Analysis of Power Dissipation in Embedded Systems Using Real-Time Operating Systems. Computer-Aided Design of Integrated Circuitand Systems, IEEE Transactionson,2003,22(5)
[42] Robert Richards. Designing RTOS for Embedded Microcontrollers. Embedded systems Programming, 1997.5
[43] Sanjeev Khushu,Johnathan Simmons. Scheduling and Synchronization in Embedded Real-Time Operating Systems. 2001
[44] V.OIive,S .Martinand ,A.VareiIle. OS for Embedded Systems. State of the Art and Prospects. Microelectronic Engineering, 2000.54(12)
[45] Wroldsen,S.Tveitane. A Real Time Operating System for Embedded Platforms. Agder University College, 2004
[46] Y. Li,M.Potkonjak,W.Wolf. Real-Time Operating Systems for Embedded Computing. IEEE, 1997: 388-392
[47] Y.Oh. The Design and Analysis of Scheduling Algorithm for Real-Time Computer Systems. Ph.D. thesis, University of Virginia, 1994
[48] Yu-Chung Wang,Kwei-Jay Lin. Enhancing the Real-time Capacity of the Linux Kernal. Real-Time Capacity of the Linux Kernal. Real-Time Computing Systems and Applications. 1998.(12):11-20 段给予的无私关心和帮助过我的老师、同学及有关单位致以最诚挚的谢意。