650 likes | 788 Views
嵌入式作業系統實作 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 SoCKernel Paper discussion. Preface.
E N D
嵌入式作業系統實作Implementation of Embedded Operating SystemsIntroduction 薛智文 cwhsueh@csie.ntu.edu.tw http://www.csie.ntu.edu.tw/~cwhsueh/
Outline • Introduction to Embedded System • Introduction to Embedded Operating System • Case Studies • SoCKernel • Paper discussion /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
Example Ethernet RS485 Ethernet RS485 /64
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 a 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
Virtual Memory /64
Multiprocessing /64
Graphics /64
File Systems /64
Networking /64
WindView /64
Stethoscope /64
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
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
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
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