9112f7cde9d6f0baed0f81bf38049c43.ppt
- Количество слайдов: 65
嵌入式作業系統實作 Implementation of Embedded Operating Systems Introduction 薛智文 cwhsueh@csie. ntu. edu. tw http: //www. csie. ntu. edu. tw/~cwhsueh/ 國立台灣大學 資訊 程學系
Outline Introduction to Embedded System Introduction to Embedded Operating System Case Studies So. CKernel Paper discussion * /64 1 資 系網媒所 NEWS實驗室
Preface Linux image files 2. 6. 4 1150 K 13400 960 5. 6 M 167 M 2. 4. 25 1177 K 11000 670 5 M 149 M 2. 2. 26 507 K 5100 280 2. 5 M 75 M 158 1 29 K 1. 5 M Thread. X 129 K directories lines bytes Window 2000, 30 M lines. Netscape Communicator 5, 17 M lines. A 圍棋 program, 0. 01 M lines. A SOHO router, 0. 6 M lines. What is Embedded (Linux/system)? * /64 2 資 系網媒所 NEWS實驗室
Embedded OS trends 2001 -2002, sorted by 2001 * /64 3 資 系網媒所 NEWS實驗室
Embedded OS trends 2001 -2002, sorted by 2002 * /64 4 資 系網媒所 NEWS實驗室
電子書包與數位學習輔具分 架構圖 數位學習平台 數位學習輔具 數 位 學 習 輔 具 Physical • Serial • USB • 1394 • Ir. DA • Bluetooth • 802. 11 開發 具 電子書包平台結構 數位學 習平台 閱讀 程式 SCORM HTML XML 電子書包教學數位內容 電子書包數位內容 開發 具 教師教學 應用軟體 教學 / 同儕群體 應用軟體開發 具 同儕群體 應用軟體 電子書包教學應用平台 系統軟體開發 具 (SDK) 相容性測試軟體 具(TCK) 電子書包作業系統 (OS / UI / CM) Protocol • Sync. ML * 電子書包發展硬體 ICE /64 DDK 5 資 系網媒所 NEWS實驗室
Example Ethernet RS 485 * /64 6 資 系網媒所 NEWS實驗室
Introduction Unix SVR 4, 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, 680 x 0, Power. PC, 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 7 資 系網媒所 NEWS實驗室
Outline Introduction to Embedded System Introduction to Embedded Operating System Software Engineering Case Studies So. CKernel Paper discussion * /64 8 資 系網媒所 NEWS實驗室
What is a Embedded System? A system designed to perform a specific function, e. g. e. Book, PDA, e. Watch, … 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 9 資 系網媒所 NEWS實驗室
Embedded System Examples Computer peripherals Keyboard, Mouse, … Information Appliances Set-Up Boxes, Web. TV, … Monitors and Sensors Fire Alarm, Heartbeat Detector, … Controllers in Electronics Refrigerator, Air Conditioner, … Communication Devices Hub, Router, … … * /64 10 資 系網媒所 NEWS實驗室
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 11 資 系網媒所 NEWS實驗室
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, … 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 12 資 系網媒所 NEWS實驗室
Real-Time Systems vs. Embedded Systems RTS ES RTES . Rad ar * . ABS . Calculat or /64 13 資 系網媒所 NEWS實驗室
Real-Time Systems Value Deadline Soft RTS Hard RTS Firm. RTS Time -Value * /64 14 資 系網媒所 NEWS實驗室
Real-Time Systems (RTS) Open Distributed Hard RTS Soft RTS Proprietary Centralized Firm RTS Embedded * /64 15 資 系網媒所 NEWS實驗室
Outline Introduction to Embedded System Introduction to Embedded Operating System Software Engineering Case Studies So. CKernel Paper discussion * /64 16 資 系網媒所 NEWS實驗室
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 17 資 系網媒所 NEWS實驗室
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 18 資 系網媒所 NEWS實驗室
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. EXT 2, EXT 3 (Journaling), Reiser. FS (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 SVR 4, popular in other Unix kernels for writing device drivers, terminal drivers, and network protocols. rejected by Linus because of performance. * /64 19 資 系網媒所 NEWS實驗室
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 20 資 系網媒所 NEWS實驗室
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 i 386 IBM-compatible personal computers based on 80 x 86 microprocessors ia 64 Workstations based on Intel 64 -bit Itanium microprocessor m 68 k Personal computers based on Motorola MC 680 x 0 microprocessors mips Workstations based on MIPS microprocessors mips 64 Workstations based on 64 -bit MIPS microprocessors parisc Workstations based on Hewlett Packard HP 9000 PA-RISC microprocessors ppc Workstations based on Motorola-IBM Power. PC microprocessors s 390 32 -bit IBM ESA/390 and z. Series mainframes s 390 x IBM 64 -bit z. Series servers sh Super. H embedded computers developed jointly by Hitachi and STMicroelectronics sparc Workstations based on Sun Microsystems SPARC microprocessors sparc 64 Workstations based on Sun Microsystems 64 -bit Ultra SPARC microprocessors Taiwan Core * /64 21 資 系網媒所 NEWS實驗室
Power Management Halting in the 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 22 資 系網媒所 NEWS實驗室
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 23 資 系網媒所 NEWS實驗室
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 24 資 系網媒所 NEWS實驗室
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 25 資 系網媒所 NEWS實驗室
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 26 資 系網媒所 NEWS實驗室
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 27 資 系網媒所 NEWS實驗室
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 MD 4, MD 5, DES, etc Support for the new NFSv 4 User interface layer Support touch screen, braille device, etc * /64 28 資 系網媒所 NEWS實驗室
Downsizing Why? 1 M 500 K 300 K 100 K 46 K 16 K 5 K How? * /64 29 資 系網媒所 NEWS實驗室
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 30 資 系網媒所 NEWS實驗室
What is a Real-Time Operating System? An operating system enforcing timing constraints, Lynx, p. SOS, Vx. Works, e. COS, u. CLinux, Lynx. OS, RTLinux, KURT, u. C/OS-II, QNX, … * /64 31 資 系網媒所 NEWS實驗室
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, + faulttolerance. * /64 32 資 系網媒所 NEWS實驗室
TORNADO II: Vx. Works 國立台灣大學 資訊 程學系
TORNADO II:Vx. Works Embedded Development Tools Vx. Works Real Time Operating System Wind Microkernel Snapshoot of Host Development Tools * /64 34 資 系網媒所 NEWS實驗室
The Next Generation of Embedded Development Tools * /64 35 資 系網媒所 NEWS實驗室
Vx. Works * /64 36 資 系網媒所 NEWS實驗室
Wind Microkernel * /64 37 資 系網媒所 NEWS實驗室
Embedded Internet * /64 38 資 系網媒所 NEWS實驗室
Virtual Memory * /64 39 資 系網媒所 NEWS實驗室
Multiprocessing * /64 40 資 系網媒所 NEWS實驗室
Graphics * /64 41 資 系網媒所 NEWS實驗室
File Systems * /64 42 資 系網媒所 NEWS實驗室
Networking * /64 43 資 系網媒所 NEWS實驗室
Wind. View * /64 44 資 系網媒所 NEWS實驗室
Stethoscope * /64 45 資 系網媒所 NEWS實驗室
Tips to be familiar with embedded boards Buy a new notebook for each of your embedded board. Lots of notes to be kept. Search for on-line and off-line manuals. Ask someone who understands the board. Call your vendors. There may be news groups to discuss all kinds questions on your venders’ homepage. Join them!! Search on Google. * /64 46 資 系網媒所 NEWS實驗室
Why Hardware? A software engineer who writes only applications may spend an entire career and learn nothing about hardware, BUT … An embedded software engineer must often: understand the hardware in order to write correct software, must install the software on the hardware, must figure out whether a problem is a software bug or hardware error, and read hardware schematic diagram and suggest corrections. * /64 47 資 系網媒所 NEWS實驗室
Overview The Linux is composed of four major subsystems. User Application O/S services Linux Kernel Hardware controller User Application O/S Services Linux Kernel Hardware Controller Decomposion of Linux system * /64 48 資 系網媒所 NEWS實驗室
Overview (Cont. ) Before we port Linux into target board, we must know hardware differences between host and target. Usually, target board has limit hardware support. It might have no MMU or floating point. Target board might support other special hardware or mechanism that host has not. * /64 49 資 系網媒所 NEWS實驗室
Linux Kernel with MMU The Linux kernel use MMU to manage memory usage. But, Samsung-S 3 C 4 does not have MMU function on it. We need to consider many part of Linux Kernel for target without MMU. * /64 50 資 系網媒所 NEWS實驗室
Linux Kernel with MMU (Cont. ) ARM MMU functions Translate virtual address into physical address Control memory access permissions Domain control Hardware requirement for MMU TLB(Translation look aside buffer) Access control logic Translation-table-walking logic * /64 51 資 系網媒所 NEWS實驗室
Linux Kernel with MMU (Cont. ) Virtual memory does more than just make your computer’s memory go further. It provides: Large address spaces Protection Memory mapping Fair physical memory allocation Shared virtual memory * /64 52 資 系網媒所 NEWS實驗室
Linux Kernel with MMU (Cont. ) Memory access control Some memory, such as that containing executable code, is naturally read only memory. The operating system should not allow a process to write data over its executable code. * /64 53 資 系網媒所 NEWS實驗室
Linux Kernel with MMU (Cont. ) Linux page table Need to translate a virtual address into a physical one. Page allocation and de-allocation Process While we create a process, Linux uses a technique called “copy on write”. The read only memory, for example the executable code, will always be shared. While the new process writes, then Linux would allocate a new page for writing. Processes use dynamic linking library to share memory. * /64 54 資 系網媒所 NEWS實驗室
Linux Kernel without MMU Linux kernel based on MMU. We must change the Linux kernel to support target devices in which has no MMU. Virtual memory The target has no MMU cannot use virtual memory to allocate memory. The function that allocate and de-allocate virtual memory are modified into physical memory allocation and de-allocation function. * /64 55 資 系網媒所 NEWS實驗室
Linux Kernel without MMU (Cont. ) Memory access control The target has no MMU cannot control memory access permissions and domain. All of the MMU control, and memory access control functions are masked to support flat memory. Flat memory model treats the entire memory on your computer the same, without artificial boundaries or special exclusions. * /64 56 資 系網媒所 NEWS實驗室
Linux Kernel without MMU (Cont. ) Page allocation and de-allocation Because of no MMU, virtual memory can not be used. All images have to be loaded to memory. Process Without MMU, processes cannot map image from file directly with ELF or A. OUT format. We convert ELF into FLAT by using application elf 2 flat. * /64 57 資 系網媒所 NEWS實驗室
Linux Kernel without MMU (Cont. ) v. Linux memory map v. Linux uses very simple memory map to support target without MMU. Page table entry is not used but reserved for other platform. Programs are loaded into free memory area when execute. * /64 58 資 系網媒所 NEWS實驗室
Linux Kernel without MMU (Cont. ) Free memory area ROOT File system Linux Kernel Page Table Entry DRAM Base * Exception Handler /64 59 資 系網媒所 NEWS實驗室
Fire. Linux Developed by Real-Time Systems Laboratory of CS Dept. at CCU Aims of this system A flexible interface for run-time dynamic loading/unloading scheduler module Support both time-driven and priority-driven scheduling approaches A micro-second resolution one-shot timer Shorten the task dispatch latency (interval between event and task switching) * /64 60 資 系網媒所 NEWS實驗室
Architecture of Fire. Linux Pinwheel EDF RM … Task 1 User Space Load/Unload Task 2 Kernel Space Flexible Scheduler Interface Fire. Timer * Scheduler Task Queue Direct Access /64 61 資 系網媒所 NEWS實驗室
• Configurable OS on SOA MP 3 System Configuration Tool Home Control MPEG 4 … User Digital Album Space SOA COS EDF RM Buddy PW Bitmap Sched Paging RT NRT Task Thread Task Kernel Space … MM Task Interfaces Kernel HAL BSP Tool Porting SOC ARM * MIPS Uni. Core /64 ISS 62 … 資 系網媒所 NEWS實驗室
Conclusion Long way to go Focus Teamwork x. Core C 1: 多媒體 A 3: Compiler SW open kernel HW patented Taiwan Core SOC Platform Configurable Power-Aware Real-Time SELF-Verification * FU A 1: 結構& SOC 平台 C 2: 網路 A 2: RTOS Qo. S B 1: 電路設計 B 3: 電性驗證 B 2: 功能驗證 /64 63 資 系網媒所 NEWS實驗室
References “Understanding the Linux Kernel (2 nd Edition), ” Daniel P. Bovert & Marco Cesati, O’Reilly, ISBN 0 -596 -00213 -0, 天瓏 "Micro. C OS II: The Real Time Kernel, " Jean J. Labrosse, CMP Books; ISBN 1578201039 "Linux Device Drivers, " 2 nd Edition, Alessandro Rubini, Jonathan Corbet, O’Reilly, ISBN 0 -596 -00008 -1, “Linkers & Loaders” by John Levine Morgan Kaufmann 2000. The official site of u. Clinux: http: //www. uclinux. org/ Arcturus Networks now officially hosting the u. Clinux project: http: //www. rt-control. com/ http: //www-106. ibm. com/developerworks/linux/library/linside. html#resources http: //kernelnewbies. org/documents/kdoc/mousedrivers. pdf http: //www. cs. ccu. edu. tw/~chsueh * /64 64 資 系網媒所 NEWS實驗室
9112f7cde9d6f0baed0f81bf38049c43.ppt