Real-Time Systems Introduction Dr. C.H. Wei Southern Taiwan University of Technology Real-Time Operating Systems (RTOS): •Operation System (作業系統) •Embedded System (嵌入式系統) •Real Time System (即時系統) •Real Time Embedded System (嵌入式即時系統) History and Future of MCU (1) M units Over 60億片 in 2003 9,000 8,000 7,000 6,000 5,000 4,000 3,000 2,000 1,000 0 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 4-Bit 8-Bit 16-Bit 32-bit+ By SEMICO In last 20 years, 8 bits MCU were domestic Application of embedded 32Bits MCU grosses rapidly History and Future of MCU (2) Total MCU Market (to 200億$) $20,000 $M $15,000 $10,000 $5,000 $0 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 4-Bit 8-Bit 16-Bit 32-bit+ Conclusion: for 8/16/32 bits MCU, 1/3 + 1/3 + 1/3 By SEMICO Problems on MCU Education • Start from Z-80 • An 8051 for everything (should be CSIC) • Use Simulators • • • • Education switches to 8/16/32 bits in parallel JTAG ONCE BDM replaces the simulator RTOS should be introduced Need renew platforms for education Typical Embedded System P O W E R KEYP AD Real Timer GSM MODULER LCD DISPLAY MAG CARD READER MCU·CORE IrDA Interface RS232 Interface IC CARD READER Memory & Decoder Thermal Printer Why RTOS? allows you to divide an application to multitasks; Simplify the application programming: • Easier to modify, extend, maintenance • Guarantee the system latency reach or close to the theoretical limits • Higher the reliability and system performance Fill the gap between application engineer & expert of Computer Multi-Tasks Bring Problems ! Races in tasks Died lock priority inversion Reentrancy Communications between tasks …… RTOS takes care of all above problems for you! • RTOS is a nice tool for Embedded System • You have to LEARN How to Use It! Commercial RTOS Products VxWorks Wind RiverSystem $40k/s & royalty wrs.com pSOS Wind RiverSystem wrs.com VRTX Microtec $20K/seat LynxOS $10K/s, Bulue Cat Linux $2.5k/seat lynuxworks.com QNX QNX qnx.com OS-9 Microware Microware.com Nucleus Accelerated Tech. $20K/s with source code CMX 8051Tools Tasking $1.29k Tasking.com RT/Studio IDE Precise $30K psti.com Embedded Linux Green Hill $7.9K Royalty free ghs.com Embedex Linux Lineo $5k/seat lineo.com Redice Linux Redsonic redsonic.com Yellow Dog linux, Hard Hat Linux, Turb Linux Montavista.com Other: Linuxnews.com LinuxDevices.com Embed.com The μC/OS Book 1992 Licensing: You do not need a license to use this code in your application, if your application is distributed in object format. You should however, indicate in your product literature that you are using μC/OS, the Real Time Kernel. If you distribute μC/OS in source code, you must obtain a license. The µC/OS-II Book 1998 License policy changed since µC/OS 1.0: You must obtain an Object Code Distribution License to embedded µC/OS-II in commercial product that is sold with the intent to make profit No licensing is required if µC/OS-II is used for education The 2nd edition of µC/OS-II June 2002 From 498 pages to 606 pages Delete 150 pages source code list. 250 new pages more From 12 Chapters to 18 Chapters Meet Requirement for Safety-Critical System June 2003 584 pages µC/OS (V1.08) vs. µC/OS-II(V2.00) 266 page to 498 pages Add more important functions: Memory manager stack usage check CPU load check µC/OS-II (V2.00 1998) vs. µC/OS-II(V2.52 2002) “MicroC/OS-II The Real-time Kernel” The Second Edit (2002) Add 250 pages more Meet Requirement for Safety-Critical System Certified by FAA Add more important functions: Mutax Semaphore, Event Flag , Debug…… Add more explanations Add Porting and Testing Real-Time Systems Mar. 2000 12 Chapters, 610 pages Real-Time Systems 1. 2. 3. 4. 5. 6. 7. 8. 9. Jane W.S. Liu Introduction Reference Model for Real-Time Systems Scheduling Approaches Clock-Driven Scheduling Practical Aspects of Cyclic Executives Priority-Driven Scheduling Resource Access Aperiodic and Sporadic Tasks Operating Systems Issues Scheduling in SystemVR4 Preemption Latency in Linux I/O Handling in Windows NT/2000 10. Data Caching in Real-Time Systems 11. Real-Time Communication 12. IETF Integrated Services 13. Network Calculus Real-Time Systems Jan. 1997 9 Chapters, 448 pages Real-Time Systems C. M. Krishna and K. G. Shin 1. Introduction. 2. Characterizing real-time tasks and systems. 3. Task assignment and scheduling. 4. Programming languages and tools. 5. Real-time databases. 6. Real-time communication. 7. Fault-tolerance techniques. 8. Reliability evaluation techniques. 9. Clock synchronization. Appendix. Review of modeling techniques. Real-Time Systems Mar. 2001 10 Chapters, 224 pages Real-Time Systems and Software Alan C. Shaw Introduction: The World of Real-Time Systems. 2. Software Architectures. 3. Requirements and Design Specifications. 4. Systems of State Machines. 5. Declarative Specifications. 6. Deterministic Scheduling. 7. Execution Time Prediction. 8. Keeping Time on Computers. 9. Programming Languages. 10. Operating Systems. Appendix: Air Traffic Control System — Project Specifications. 1. Real-Time Concepts for Embedded Systems July 2003 16 Chapters, 294 pages Real-Time Concepts for Embedded Systems 1. Introduction 2. Basics of developing for embedded systems 3. Embedded system initialisation 4. Tasks 5. Semaphores 6. Message queues 7. Other kernel objects 8. Other RTOS services 9. Exceptions 10. I/O subsystem 11. Memory management µC/OS Already Widely Used in Many Fields Already used in the field since 1992 such as: cameras medical instruments musical instruments engine control network adapter highway telephone call box ATM machine industrial robots…… Since 1995, ported it to MC68HC11, M68000, CPU32,M.core,HC08 and used it in several projects: Digital Data Log MCU based TCP/IP stack µC/OS, µC/OS –II the RT Kernel Dedicated Designed for Embedded System Priority based preemptive kernel (simple algorithm) Above 90% is written in C, easy for porting Scalable and ROM able Source code for PC environment attached with a CD Very detail explanation in excellent programming style So good for education! RTOS Kernel Source Code µC/OS-II Service OSTaskCreat() OSTaskDell() RTOS Kernel Enter_Critical() Exit_Critical() Schedule_lock() ScheduleUnlock() TaskChangePrio() …... Available Compilers • Diab data (now part of Windriver) – ANSI-c / c++ – Platforms: windows 95, windows NT, OS/2, Solaris, SunOS, HP/UX, IRIX, aix, – Http://www.WindRiver.Com/products/html/dcc_compiler.Html • Green hills – Standard C++, extended embedded C++ – Host platforms: windows 95, 98, NT and sparc/solaris – Http://www.Ghs.Com/products/mcore_development.Html • Hiware – ANSI-C / C++ / EC++ / cc++ compilers – Host platforms: windows 95, 98, NT – Http://www.Hiware.Com/p_mcore.Html • Metrowerks – ANSI C compliant, ANSI/ISO C++ compliant and EC+ compilers – Host platforms: windows 95, 98 and NT – Http://www.Metrowerks.Com/embedded/mcore/ • Motorola GNU toolkit – GNU C and C++ compilers – Http://sarl.Corp.Mot.Com/mcore/gnu/ Free C Compile: GNU gcc Tolls •GNU gcc Tools •Cross C Compiler for: M68K, CPU32, Coldfire, M.Core, PowerPC, 68HC11/12,SPARC,PA,RISC,VAX,AMD29K, ARM,Thumb,MN10xxx, M32, SR6000,MIPS, RT, i386, Inter960,TMS32, DEC alpha, V850,NS32K •Cross assembler : AS •Disassemble: Objdump •Liker: Ld •C support lib: Libc & Libm •Gcc Debug options –You know GCC , You will get also Embedded ucLinux Porting µC/OS –II • Compiler with Hiware • Down loaded with Picobug Or: • Compiler with CodeWarrior • Down loaded with EDBI tool uCLinux in Linux • Take off the Memory Management – Good for the non-mmu CPU in Embedded • • • • Free OS for Embedded Many application program in Linux available Not a Real Time OS !Download RTLinux3.1 from:www.rtlinux.org Much smaller than Linux, sometimes still too large for Embedded system typical RAM usage ~512K • Down load from: www.uclinux.org