4 2005 * 1 1, 2,, 2 1, 2, ( 1., 200072; 2., 510515) : RT-Linux, CLinux, C/ OS- ecos ( Embedded Real- Time Operating Systems, ERTOS),, ERTOS : ; ; ; ; ; : TP316. 2 : A : 1001-3695( 2005) 09-0004- 05 Analysis of Key Techniques Based on Four Embedded Real-Time Operating Systems JI Zhi-jun 1, MA Wen-li 1, 2, CHEN Hu 2, ZHENG Wen-ling 1, 2 ( 1. Bio-electronics Research Center, Shanghai University, Shanghai 200072, China; 2. Institute of Genetic Engineering, Nanfang Medical U- niversity, Guangzhou Guangdong 510515, China) Abstract: The paper reviews four embedded real-time operating systems, namely the RT-Linux, CLinux, C/ OS-and ecos. The key ERTOS procedures are compared and analyzed systematically, which include task scheduling, task synchronizing and communicating, memory allocating, interrupt handling and so on. The ERTOS s applications are discussed. Key words: Embedded System; Real-Time Operating System; Task Scheduling; Task Synchronizing and Communicating; Memory Allocating; Interrupt Handling ERTOS 1 2 ERTOS, ( 1) RT-Linux, RT-Linux Victor Yo-, daiken Michael Brananov, FSMlabs ( Hard Real Time) ( Soft Real Time) RT-Linux Linux,,, ( ISR) Linux Linux,,, Linux Linux,, ( Real-Time Operating System, RTOS), ( 2) CLinux,, CLinux GNU/ GPL, ( Embeded Real-Time Operating System, ERTOS), Lineo CLinux ERTOS, Nucle- : Micro, C Control, CLinux Microus Plus, QNX, LynxOS, psos, VRTX, VxWorks, Windows CE, Control-Linux, Linux Hopen( ), Palm OS, RT-Linux, CLinux ( MMU), CLinux, C/ OS-, ecos ERTOS CPU,, CLinux RT-Linux, CLinux, C/ OS- ecos ERTOS, Linux, Linux,, : 2004-08- 16; : 2004-09- 28 : ( 39880018) ; C/ OS- ( 199-Z005-001), API ( 3) C / OS-, Jean J. Labrosse C
9 : 5,, Micrium, C/ OS-, C/ ( ) C/ OS- 60,, ( 2) ( 4) ecos ecos Embedded Configurable Operating System, Cygnus Solution, Redhat,, ecoscentric ecos, ( ) ecos, ( 3) ; ( ) ; ; ; ; CPU, ; ; ; CPU ISO C ; API, POSIX API, EL/ IX ITRON 3. 02 API ; TCP/ IP ; JFFS2 Flash, RAM ROM ;, ( Rate-Monotonic Scheduling, ERTOS ecos RMS) ( Earlist-Deadline First, EDF),, ( 5) ERTOS ERTOSAPI CPU, ERTOS, 1 1 ERTOS R T-Linux CLinux C / OS- ecos FEMLabs Lineo Mic rium ecoscentric POSIX API 1003. 13 API Linux API; TCP / IP, ; IX ; ITR ON C / FS TCP ; / IP 60 POSIX API; EL / 3. 02 A PI; TCP / IP CPU 16 16 64 8 32 16 64 CPU PC, x86, Power- Strong- AR M, A lpha, MIPS Motorola 68 k / Dragonball / Coldfire, AR M 7TDMI, Power PC, A xis ETR AX, Intel i960, PRISMA, MC68 EN302 8051 AR M PowerPC Motorola 68 k / x86nec V 850 EColdfire MIPS SPA RClite AR M x86 StrongA rm X s- cale PowerPC NEC V 8xx SPA RCSuperH Matsushita AM3x 1. 5 MB ROM KB 512KB R AM KB ROM 4MB R A M KB ROM 1 MB R OM / Flash RA M ( MiniRT-Linux) R AM MMU UNIX, Windows Linux Linux Linux C GNU GNU 3 ERTOS Linux Windows Cygwin GNU ; ; RT-Linux ; ; CPU CLinux Linux ERTOS 3. 1 ERTOS, ERTOS, : RT-Linux RTAI ( http: / / www. aero. polimi. it/ rtai/ ) Linux-in-an-ERTOS ( 1), CPU, ( 4),, ( 5) ERTOS, ERTOS, 2 2 R T-Linux ( ) ERTOS CLinux C / OS- ecos ( ) ; ; ( R MS ) ; ; ( EDF) 1024 ( ) 1 00 64 32 ( ) 32 ( ) 64( 32 ( ) 5 6) RT-Linux Linux, Linux,,, (, ), CPU C/ OS-,
6 2005,, :, C/OS- ; OSRdyGrp OSRdyTbl [ 0.. 7] OSS-, ched( ), 64, ecos, 2. 0 ecos, ( Bitmap),, ( Multi-Level Queue, MLQ),, ( 32 2 ),, 32, 32, ( SMP) MLQ FIFO MLQ FIFO,, / ERTOS, 3 MLQ, 3 ERTOS, ecos, 3. 2 ERTOS,,, ERTOS 3. 3 ( Semaphore) ( Mutex) ( Event ERTOS, : Flag) ( Asynchronous Signal), ( Message Box) ( Message Query) ( Pipe) ( Shared Memory), ERTOS, ( 3) ( Priority Ceiling Protocol) : ( Priority Inheritance Protocol) R T-Linux CLinux C / OS- ecos FIFO, : R T-Linux Linux, FIFOMBUFF ( 1) :, ERTOS,, / ( Priority Inversion) :,, ERTOS :, :,,,,, ( 2),, 1 ERTOS,, 任务 1( 高 ) 任务 2( 中 ) 任务 3( 低 ) 任务 3 得到互斥量任务 1 剥夺任务 3 的 CPU 使用权任务 1 需要获得任务 3 占有的互斥量, 由于互斥量还被任务 3 占用, 任务 1 只好挂起, 任务 3 继续运行任务 2 剥夺任务 3 的 CPU 使用权 图 1 优先级反转 任务 2 运行结果, 任务 3 重新运行任务 3 释放互斥量, 继续运行任务 1 优先级倒置问题 互斥量挂起运行 任务 1( 高 ) 任务 2( 中 ) 任务 3( 低 ) 任务 3 得到互斥量 任务 1 剥夺任务 3 的 CPU 使用权任务 1 需要获得任务 3 占有的互斥量, 由于互斥量还被任务 3 占用, 任务 1 只好挂起, 任务 3 的优先级被提升到任务 1 的水平继续运行 图 2 优先级反转 任务 1 运行完成, 运行任务 2 任务 3 释放互斥量, 继续运行任务 1 内核支持优先级继承 互斥量挂起运行,, : ;, ; ( MMU), ERTOS,,,
9 : 7, ecos,,,,, ecos,,, ecos, (, RT-Linux),, Cyg_Mempoolt Cyg_Mempolt2, : : ( Variable Size Memory Pool),, ;, ( Fixed Size Memory Pool),,, ecos, ecos C malloc ( ), 4 ERTOS R T-Linux CLinux C / OS- ecos MMU,, RT-Linux, ( 1) RT-Linux,, RT-Linux Linux RT-Linux Linux Linux,, Linux RT-Linux Linux, Linux, MBUFF ( mbuff_alloc, mbuff_free) RT-Linux Linux RT-Linux,, RT-, Linux RT-Linux malloc( ) free( ) CLinux MMU,, Linux, ( Real Memory Management), Linux,,, Linux,, Linux Linux C/ OS-,, RT-Linux ; RT-Linux, Linux, C/ OS- Linux IRQ,,, IRQ, ( 2) CLinux, C/OS- malloc ( ) free( ) ecos,,, 3. 4 malloc( ) free( ) ERTOS, ERTOS, 4, ERTOS ERTOS,, ERTOS, ERTOS IRQ ISR, ISR,, ERTOS, Linux Linux, ;, CLinux, Linux,,, : ( Top Half) ( Bottom Half),,,,, C/ OS- mal-, loc( ) free( ),,,,, Linux,,
8 2005, Linux,, ( 2) CLinux, Linux, Linux, ( 3) C/ OS- C/ OS-, ERTOS ISR, C/ OS- ISR, ISR,, OSIntEnter( ) OSIntExit( ) ERTOS, OSIntEnter( ) ISR, C/ OS-, 255 ISR, OSInt- Exit( ) ( 4) ecos, ecos,,,,,, ( 4) ecos ecos, Productivity Center, MPC) Iomega Hip Zip Ik-, ISR ( Deferred endi Service Routine, DSR) Linux : DSR, [ 2]. ARM CPU C/OS-, Clinux, Linux[ J]., 2004, ( 2) : 38-40., [ 3]. C/OS-CLinux [ J]., 2002,, ISR ( 10 ) : 18-20. DSR,, ISR,, ISR, DSR, ecos [ 6] Ismael Ripoll. RTLinux Versus RTAI[ EB/ OL]. http: / / bernia. disca. upv. es / rtportal/ comparative / rtl_vs_rtai. html, 2002-10 DSR,. DSR, [ 7] Herman Bruyninckx. Real-time and Embedded Guide[ M/ OL]. http: / /people. mech. kuleuven. ac. be/ bruyninc / rthowto/rthowto., DSR, ISR, ecos DSR, DSR, ISR [ 9 ] USB. uclinux[ EB /OL]. http: / /www. usbing. net/ Article_Show. asp? ArticleID = 114, 2004-8. DSR [ 10]. ARM Clinux Web : RT-Linux, [ D]. :, 2003. ; CLinux, [ 11]. ARM SNMP [ D]. ; C/OS-,, :, 2003. [ 12] Jean J. C/ OS- ( 2 ) ; ecos,, [ M]. Labrosse.,. :, 2003. 4 [ 14] Anthony J Massa. Embedded Software Development with ecos[ M]. ERTOS New Jersey: Prentice Hall PTR, 2002., [ 15]. PC ecos [ D]. :, ERTOS : CLinux MMU,, ( 3) C/OS-, RAM ROM,, Brother HL- 2400 CeN Delphi Com- muniport ( MPU) ( Mobile [ 1]. [ J]., 2003, ( 10) : 26-27., ISR [ 4 ] FSMlabs. RT-Linux Articles and Documentation[ EB / OL]. http: / /www. fsmlabs. com/ articles /articles. html, 2004-08- 01. [ 5],,. Linux [ J]., 2004, 27( 2 ) : 244-251. pdf, 2002-12- 11. [ 8],. Linux ( ) [ M]. :, 2001. [ 13]. ecos [ M]. :, 2004., 2002. ( 1) RT-Linux : ( 1977 - ),,,, RT-Linux Linux ;,,,, Linux, ;,,, ;,,,,,