Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating...
-
date post
19-Dec-2015 -
Category
Documents
-
view
238 -
download
8
Transcript of Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating...
![Page 1: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/1.jpg)
Chapter 13Embedded Systems
Dave BremerOtago Polytechnic, N.Z.
©2008, Prentice Hall
Operating Systems:Internals and Design Principles, 6/E
William Stallings
![Page 2: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/2.jpg)
Roadmap
• Embedded Systems• Characteristics of Embedded Operating
Systems• eCos• TinyOS
![Page 3: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/3.jpg)
Embedded System
• One of the most important and widely used categories of operating systems
• Hardware and software designed to perform a dedicated function
• Tightly coupled to their environment• Often, embedded systems are part of a
larger system or product, – E.G. antilock braking system in a car.
![Page 4: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/4.jpg)
Real Time
• Embedded systems are tightly coupled to their environment.
• This imposes real-time constraints by the need to interact with the environment. – required speeds of motion, – required precision of measurement, – required time durations.
![Page 5: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/5.jpg)
Examples of Embedded Devices
![Page 6: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/6.jpg)
Embedded System Organization
![Page 7: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/7.jpg)
Differences from typical computer
• A variety of Interfaces.• Use of a diagnostic.• Special purpose hardware may be used to
increase performance or safety.– Field programmable (FPGA), – application specific (ASIC),– or even nondigital hardware.
• Single purpose software.
![Page 8: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/8.jpg)
Roadmap
• Embedded Systems• Characteristics of Embedded Operating
Systems• eCos• TinyOS
![Page 9: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/9.jpg)
Characteristics of Embedded OS
• Real-time operation• Reactive operation• Configurability• I/O device flexibility• Streamlined protection mechanisms• Direct use of interrupts
![Page 10: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/10.jpg)
Developing anEmbedded OS
• Two general approaches– Take an existing OS and adapt it for
embedded purposes– Design a purpose-built OS solely for
embedded use
![Page 11: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/11.jpg)
Adapting an Existing OS
• Examples include Windows, Linux, BSD– Generally slower than special purpose OS– Advantage is familiar interface
• Need to add – real-time capability– Streamlining operation– Add other specialized and necessary
functionality for the given device
![Page 12: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/12.jpg)
Purpose-Built Embedded OS
• Typical characteristics include:– fast and lightweight process or thread switch– Scheduling policy is real time and dispatcher
module is part of scheduler– Small size– Responds to external interrupts quickly– Minimizes intervals during which interrupts
are disabled
![Page 13: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/13.jpg)
Timing Constraints
• To deal with timing constraints, the kernel:– Provides bounded execution time for
primitives– Maintains a real-time clock– Provides for special alarms and timeouts– Supports real-time queuing disciplines – Provides primitives to delay processing by a
fixed amount of time and to suspend/resume execution
![Page 14: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/14.jpg)
Roadmap
• Embedded Systems• Characteristics of Embedded Operating
Systems• eCos• TinyOS
![Page 15: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/15.jpg)
eCos: Embedded Configurable OS
• Open source, Royalty-free• Real-time OS• Most widely used embedded OS• Targeted at high-performance small
embedded systems. • An embedded form of Linux or other
commercial OS would not provide the streamlined software required.
![Page 16: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/16.jpg)
eCos Configuration Tool
![Page 17: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/17.jpg)
eCos Configuration Tool
![Page 18: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/18.jpg)
Loading an eCos Configuration
![Page 19: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/19.jpg)
eCos Layered Structure
![Page 20: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/20.jpg)
Hardware Abstraction Layer
• Presents consistent API to upper layers
• Different for each hardware platform
![Page 21: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/21.jpg)
HAL
![Page 22: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/22.jpg)
HAL Modules
• Architecture– Processor family type
• Variant– Support features of specific processor
• Platform– Support of tightly coupled peripherals
![Page 23: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/23.jpg)
eCos Kernel Design
• The eCos kernel was designed to satisfy four main objectives:– Low interrupt latency– Low task switching latency– Small memory footprint– Deterministic behavior
![Page 24: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/24.jpg)
Not in eCos Kernel
• Memory allocation• Device driver• This makes for a lean kernel.
![Page 25: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/25.jpg)
eCos I/O System
• Framework for supporting device drivers• A variety of drivers are available through
the configuration package• Principle objective is efficiency with no
unnecessary software layering
![Page 26: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/26.jpg)
eCos Scheduler
• Bitmap scheduler– Efficient for small number of threads active– Each thread has different priority
• Multilevel queue scheduler– Appropriate when number of threads is
dynamic– Multiple threads at each priority– Time slicing
![Page 27: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/27.jpg)
Bitmap Scheduler Priority Levels
![Page 28: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/28.jpg)
Multilevel Queue Scheduler Priorities
![Page 29: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/29.jpg)
eCos Thread Synchronization
• Classic mechanisims– Mutexes– Semaphores– Condition variables
• synchronization/communication mechanisms – Event flags– Mailboxes
• SMP support(symmetric multiprocessing)– Spinlocks
![Page 30: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/30.jpg)
Mutexes
![Page 31: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/31.jpg)
Mutexes and Condition Variables
![Page 32: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/32.jpg)
Mutexes and Condition Variables
![Page 33: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/33.jpg)
Roadmap
• Embedded Systems• Characteristics of Embedded Operating
Systems• eCos• TinyOS
![Page 34: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/34.jpg)
TinyOS
• 400 bytes of code• Not a real-time OS
– No kernel– There are no processes; – OS doesn’t have a memory allocation system – interrupt and exception handling is
dependent on the peripheral; and– Nonblocking, so there are few explicit
synchronization primitives.
![Page 35: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/35.jpg)
Wireless Sensor Network Topology
![Page 36: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/36.jpg)
TinyOS Goals
• With the tiny distributed sensor application in mind, the following goals were set for TinyOS:– Allow high concurrency– Operate with limited resources– Adapt to hardware evolution– Support a wide range of applications– Support a diverse set of platforms– Be robust
![Page 37: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/37.jpg)
TinyOS Components
• Embedded software systems built with TinyOS consist of a set of modules – called components
• Such as:– Single-hop networking– Ad-hoc routing– Power management– Times– Nonvolatile storage control
![Page 38: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/38.jpg)
TimerM Component
![Page 39: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/39.jpg)
TimerM Configuration
![Page 40: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/40.jpg)
TinyOS Scheduler
• Operates across all components• Only one task executes at one time• Simple FIFO queue• Schedular is power aware
– Puts processor to sleep when no task in queue
![Page 41: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/41.jpg)
Surge: An Example TinyOS Application
![Page 42: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/42.jpg)
Configuration for Surge
![Page 43: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/43.jpg)
TinyOS Resource Interface
• TinyOS provides a simple but powerful set of conventions for dealing with resources.– Dedicated– Virtualized– Shared
![Page 44: Chapter 13 Embedded Systems Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.](https://reader036.fdocuments.in/reader036/viewer/2022081503/56649d2c5503460f94a02738/html5/thumbnails/44.jpg)
Shared Resource Configuration