770 likes | 909 Views
嵌入式作業系統實作 Implementation of Embedded Operating Systems Introduction. 薛智文 cwhsueh@csie.ntu.edu.tw http://www.csie.ntu.edu.tw/~cwhsueh/. Rules in Class. Be on Time for class, deliverable, … Food is OK but no alcohol. Nap is OK but no snoring. Ask questions in classes, not between.
E N D
嵌入式作業系統實作Implementation of Embedded Operating SystemsIntroduction 薛智文 cwhsueh@csie.ntu.edu.tw http://www.csie.ntu.edu.tw/~cwhsueh/
Rules in Class • Be on Time for class, deliverable, … • Food is OK but no alcohol. • Nap is OK but no snoring. • Ask questions in classes, not between. • Do participate. • Course Outline is a reference. /5
Outline • Introduction to Embedded System • Introduction to Embedded Operating System • Case Studies • SoCKernel /64
Preface • Window 2000, 30M lines. • Netscape Communicator 5, 17M lines. • A 圍棋 program, 0.01M lines. • A SOHO router, 0.6M lines. • What is Embedded (Linux/system)? /64
電子書包與數位學習輔具分工架構圖 數位學習平台 數位學習輔具 開發工具 電子書包平台結構 數位學習輔具 數位學習平台閱讀 程式SCORM HTML XML 電子書包數位內容 開發工具 電子書包教學數位內容 • Physical • Serial • USB • 1394 • IrDA • Bluetooth • 802.11 教學 / 同儕群體 應用軟體開發工具 教師教學應用軟體 同儕群體應用軟體 電子書包教學應用平台 系統軟體開發工具 (SDK) 相容性測試軟體工具(TCK) 電子書包作業系統 (OS / UI / CM) • Protocol • SyncML 電子書包發展硬體 ICE DDK /64
Tinix’-“自己動手寫作業系統,” 于淵 org 07c00h ; tell the assembler to load onto 7c00, 0100h for DOS mov ax, cs mov ds, ax mov es, ax call DispStr ; call string display procedure jmp $ ; infinite loop DispStr: mov ax, BootMessage mov bp, ax ; ES:BP = string address mov cx, 16 ; CX = string length mov ax, 01301h ; AH = 13, AL = 01h mov bx, 000ch ; page number is 0 (BH = 0) black background red character ; (BL = 0Ch,highlight) mov dl, 0 int 10h ; the 10h software interrupt ret BootMessage: db "Hello, OS world!" times 510-($-$$) db 0 ; fill the rest of sector (512 bytes) with 0 dw 0xaa55 ; end of sector
Example Ethernet RS485 Ethernet RS485 /64
在嵌入式軟體開發中採用的作業環境 EE Times-Asia, 2006 Dec /257
在設計專案中採用即時作業系統 EE Times-Asia, 2006 Dec /257
在嵌入式應用開發中採用的語言EE Times-Asia, 2006 Dec /257
不同工具的重要性及工程師滿意程度 /257
嵌入式設計中前10名軟硬體開發工具 /257
Introduction • Unix SVR4, System V Release 4, AT&T, now owned by Santa Cruz Operation, Inc.; • 4.4 BSD, UC Berkeley • Digital Unix, DEC Compaq HP • AIX, IBM • HP-UX, HP • Solaris, Sun Microsystems, Stanford University • Linux, 1991 Linus Torvalds on 80386 Alpha, SPARC, 680x0, PowerPC, IBM 390, ARM, … • A Unix kernel with other applications available under GNU General Public License • GNU’s Not Unix • POSIX, Portable OS based on Unix /64
Outline • Introduction to Embedded System • Introduction to Embedded Operating System • Software Engineering • Case Studies • SoCKernel • Paper discussion /64
What is an Embedded System? • A system designed to perform a specific function, e.g. eBook, PDA, eWatch, … • A combination of computer hardware and software, and perhaps additional mechanical or other parts. • Embedded vs. General-Purpose • What is a specific function? • Is there a limitation? • Cost, Robust, Low-power, Small, … • Using C + Assembly, Java ? /64
Embedded System Examples • Computer peripherals • Keyboard, Mouse, … • Information Appliances • Set-Up Boxes, WebTV, … • Monitors and Sensors • Fire Alarm, Heartbeat Detector, … • Controllers in Electronics • Refrigerator, Air Conditioner, … • Communication Devices • Hub, Router, … • … /64
Business Issues of ES • Time-to-market for new devices • Design to delivery: in weeks • Sustained pressure to reduce costs • Many proprietary choices yield low-margins • Life cycle management • New products overlapping each other • Positioning nightmares • Open platform choices considered risky? • Resources expended on “recreating the wheel…” not on product differentiation. /64
ES Technology Issues • Need more complex technology integrated for new services • broadband, wireless, real-time, low-power, … • Multiple emerging standards need to be deployed simultaneously. • Product released globally on the same day! • Tools, Tools, Tools, … • Third party software • No one company can do it all anymore • Support nightmares • Lack of sources from proprietary choices • Open sources sound seductive … but risky. /64
Real-Time Systems vs. Embedded Systems RTS ES RTES .ABS .Radar .Calculator /64
Real-Time Systems Value Deadline Soft RTS Hard RTS FirmRTS Time -Value /64
Real-Time Systems (RTS) Open Distributed Soft RTS Hard RTS Proprietary Centralized Firm RTS Embedded /64
Outline • Introduction to Embedded System • Introduction to Embedded Operating System • Software Engineering • Case Studies • SoCKernel • Paper discussion /64
Linux • 2.2 Aims to be compliant with IEEE POSIX • Source codes from other Unix-like kernel can be compiled and executed with little efforts, even without patches. • Include modern OS features, i.e. virtual memory, virtual filesystem, lightweight processes, signals, IPC, SMP, … • Was not very innovative except General Public License (GPL). /64
Linux vs. Other Unix-Like Kernels • Linux kernel is monolithic. • Same as most other Unix variants while Mach 3.0, uses microkernel (task management + semaphore + timer), from CMU • Linux supports modules. • Traditional kernels are compiled and linked statically. • Limited kernel threads • can not execute user programs, • Nonstandard lightweight process, using clone(). • Linux is a nonpreemptive kernel. • Only Solaris 2.x, Mach 3.0 are fully preemptive. • Introduce fixed preemption points to cure. /64
Linux vs. Other Unix-Like Kernels (cont.) • Multiprocessor support after 2.2. • filesystem and network operation still remain sequential. • Filesystem is standard but is easy to port other filesystem through VFS. • EXT2, EXT3 (Journaling), ReiserFS (small files) • IBM AIX, Journaling File System • SGI Irix, XFS filesystem, for big volume, guaranteed I/O rate, and journaling. • No STREAMS I/O subsystem, from SVR4, popular in other Unix kernels for writing device drivers, terminal drivers, and network protocols. • rejected by Linus because of performance. /64
Why Linux? • Free, no charge. • Free, fully customizable in all components. • Runs on low-end cheap HW platforms. • Embedded Linux is very hot. • Powerful. • open source so as to fully utilize HW. • High standard for source code quality. • low failure rate and maintenance time. • Kernel can be very small and compact. • Highly compatible with other OSes. • Filesystem, networking, code executed directly. • Well supported. /64
Hardware Dependency • Linux maintains a neat distinction between hardware-dependent and hardware-independent source code. • alpha Hewlett-Packard's Alpha workstations • arm ARM processor-based computers and embedded devices • cris "Code Reduced Instruction Set" CPUs used by Axis in its thin-servers, such as web cameras or development boards • i386 IBM-compatible personal computers based on 80 x 86 microprocessors • ia64 Workstations based on Intel 64-bit Itanium microprocessor • m68k Personal computers based on Motorola MC680 x 0 microprocessors • mips Workstations based on MIPS microprocessors • mips64 Workstations based on 64-bit MIPS microprocessors • parisc Workstations based on Hewlett Packard HP 9000 PA-RISC microprocessors • ppc Workstations based on Motorola-IBM PowerPC microprocessors • s390 32-bit IBM ESA/390 and zSeries mainframes • s390 x IBM 64-bit zSeries servers • sh SuperH embedded computers developed jointly by Hitachi and STMicroelectronics • sparc Workstations based on Sun Microsystems SPARC microprocessors • sparc64 Workstations based on Sun Microsystems 64-bit Ultra SPARC microprocessors • Taiwan Core /64
Power Management • Halting in the idle process • idle process executes hlt on Intel • low-power consumption mode • Suspending the system • patches for suspending to disk • APM: Advance Power Management • laptop standard power management • ACPI: Advanced Configuration and Power Interface • new comprehensive standard from Intel-Microsoft • Power-management is essential for mobile systems /64
Linux 2.6 Highlights • New scheduler • New architectures and processor types have been added – including support for MMU-less systems • New set of drivers for audio and multimedia have been added • Others (kernel core dumping, fast mutex support, an improved I/O subsysem etc.) /64
2.4 vs. 2.6 Kernel 2.4 had • A Global runqueue. • All CPUs had to wait for other CPUs to finish execution. • An O(n) scheduler. • In 2.4, the scheduler used to go through the entire “ global runqueue” to determine the next task to be run. • This was an O(n) algorithm where 'n' is the number of processes. The time taken was proportional to the number of active processes in the system. • This lead to large performance hits during heavy workloads. /64
Driver Porting to Linux 2.6 • Quicker kernel build system • New set of module utilities • Makefiles for 2.4 won’t work in 2.6 • .ko module object instead of an .o • module_init and module_exit instead of init_module and cleanup_module • New module loading utility minimize the occurrence of race conditions • The module usage count move to outside of module code /64
Workqueue Interface • Used to schedule kernel tasks • Each workqueue has dedicated worker threads associated with it and all the tasks from the run queue run in the context of the process • Driver can use the default workqueue provided by the kernel /64
Other Notable Changes • File systems • IBM’s JFS ( journaling file system ) and SGI’s XFS have been merged into 2.6 • Audio • New Linux audio architecture ALSA (Advanced Linux Sound Architecture) replaces OSS (Open Sound System) /64
Other Notable Changes • Power management • Support for ACPI (Advanced Configuration and Power Interface), for CPU scaling • Under testing • Networking and IPSec • The IPSec feature uses the new crypto API, including MD4, MD5, DES, etc • Support for the new NFSv4 • User interface layer • Support touch screen, braille device, etc /64
Downsizing • Why? • 1M 500K 300K 100K 46K 16K 5K • How? /64
What is a Real-Time System? • A system enforcing timing constraints, e.g. Avionics, Missile Control, … • The correctness of the system depends not only on the logical result of the computation, but also on the time at which the results are produced. • Real-Time vs. High Performance • What is a timing constraint? • A constraint of timing requirements, e.g. period, distance, deadline, ready time, … • Functional and temporal correct. /64
What is a Real-Time Operating System? • An operating system enforcing timing constraints, Lynx, pSOS, VxWorks, eCOS, uCLinux, LynxOS, RTLinux, KURT, uC/OS-II, QNX, … /64
Systems Issues • In RTS, the OS and AP are very tightly coupled, than time-sharing systems. • shared memory, special buses (instruction, data, event, memory, control, invalidate, …). • A RTOS must response to internal and external events deterministically. • Low-priority tasks may wait for high-priority task or events indefinitely. • System architecture needs to provide high computational speed, high-speed interrupt handling, and high I/O throughput, + fault-tolerance. /64
TORNADO II:VxWorks • Embedded Development Tools • VxWorks Real Time Operating System • Wind Microkernel • Snapshoot of Host Development Tools /64
VxWorks /64
Wind Microkernel /64