Chapter13 New

download Chapter13 New

of 44

Transcript of Chapter13 New

  • 7/30/2019 Chapter13 New

    1/44

    Chapter 13

    Embedded Systems

    Dave Bremer

    Otago Polytechnic, N.Z.2008, Prentice Hall

    Operating Systems:Internals and Design Principles, 6/E

    William Stallings

  • 7/30/2019 Chapter13 New

    2/44

    Roadmap

    Embedded Systems

    Characteristics of Embedded Operating

    Systems

    eCos

    TinyOS

  • 7/30/2019 Chapter13 New

    3/44

    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 alarger system or product,

    E.G. antilock braking system in a car.

  • 7/30/2019 Chapter13 New

    4/44

    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.

  • 7/30/2019 Chapter13 New

    5/44

    Examples of

    Embedded Devices

  • 7/30/2019 Chapter13 New

    6/44

    Embedded System

    Organization

  • 7/30/2019 Chapter13 New

    7/44

    Differences from

    typical computer A variety of Interfaces.

    Use of a diagnostic.

    Special purpose hardware may be used toincrease performance or safety.

    Field programmable (FPGA),

    application specific (ASIC),

    or even nondigital hardware.

    Single purpose software.

  • 7/30/2019 Chapter13 New

    8/44

    Roadmap

    Embedded Systems

    Characteristics of Embedded Operating

    Systems

    eCos

    TinyOS

  • 7/30/2019 Chapter13 New

    9/44

    Characteristics of

    Embedded OS Real-time operation

    Reactive operation

    Configurability I/O device flexibility

    Streamlined protection mechanisms

    Direct use of interrupts

  • 7/30/2019 Chapter13 New

    10/44

    Developing an

    Embedded OS Two general approaches

    Take an existing OS and adapt it for

    embedded purposes

    Design a purpose-built OS solely for

    embedded use

  • 7/30/2019 Chapter13 New

    11/44

    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

  • 7/30/2019 Chapter13 New

    12/44

    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 interruptsare disabled

  • 7/30/2019 Chapter13 New

    13/44

    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 afixed amount of time and to suspend/resume

    execution

  • 7/30/2019 Chapter13 New

    14/44

    Roadmap

    Embedded Systems

    Characteristics of Embedded Operating

    Systems

    eCos

    TinyOS

  • 7/30/2019 Chapter13 New

    15/44

    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 othercommercial OS would not provide the

    streamlined software required.

  • 7/30/2019 Chapter13 New

    16/44

    eCos Configuration Tool

  • 7/30/2019 Chapter13 New

    17/44

    eCos Configuration Tool

  • 7/30/2019 Chapter13 New

    18/44

    Loading an eCos

    Configuration

  • 7/30/2019 Chapter13 New

    19/44

    eCos

    Layered Structure

  • 7/30/2019 Chapter13 New

    20/44

    Hardware

    Abstraction Layer Presents consistent

    API to upper layers

    Different for each

    hardware platform

  • 7/30/2019 Chapter13 New

    21/44

    HAL

  • 7/30/2019 Chapter13 New

    22/44

    HAL Modules

    Architecture

    Processor family type

    Variant

    Support features of specific processor

    Platform

    Support of tightly coupled peripherals

  • 7/30/2019 Chapter13 New

    23/44

    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

  • 7/30/2019 Chapter13 New

    24/44

    Not in eCos Kernel

    Memory allocation

    Device driver

    This makes for a lean kernel.

  • 7/30/2019 Chapter13 New

    25/44

    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

  • 7/30/2019 Chapter13 New

    26/44

    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

  • 7/30/2019 Chapter13 New

    27/44

    Bitmap Scheduler

    Priority Levels

  • 7/30/2019 Chapter13 New

    28/44

    Multilevel Queue

    Scheduler Priorities

  • 7/30/2019 Chapter13 New

    29/44

    eCos Thread

    Synchronization Classic mechanisims

    Mutexes

    Semaphores

    Condition variables synchronization/communication mechanisms

    Event flags

    Mailboxes

    SMP support(symmetric multiprocessing) Spinlocks

  • 7/30/2019 Chapter13 New

    30/44

    Mutexes

  • 7/30/2019 Chapter13 New

    31/44

    Mutexes and Condition

    Variables

  • 7/30/2019 Chapter13 New

    32/44

    Mutexes and Condition

    Variables

  • 7/30/2019 Chapter13 New

    33/44

    Roadmap

    Embedded Systems

    Characteristics of Embedded Operating

    Systems

    eCos

    TinyOS

  • 7/30/2019 Chapter13 New

    34/44

    TinyOS

    400 bytes of code

    Not a real-time OS

    No kernel

    There are no processes;

    OS doesnt have a memory allocation system

    interrupt and exception handling is

    dependent on the peripheral; and

    Nonblocking, so there are few explicit

    synchronization primitives.

  • 7/30/2019 Chapter13 New

    35/44

    Wireless Sensor Network

    Topology

  • 7/30/2019 Chapter13 New

    36/44

    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

  • 7/30/2019 Chapter13 New

    37/44

    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

  • 7/30/2019 Chapter13 New

    38/44

    TimerM Component

  • 7/30/2019 Chapter13 New

    39/44

    TimerM Configuration

  • 7/30/2019 Chapter13 New

    40/44

    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

    S A E l

  • 7/30/2019 Chapter13 New

    41/44

    Surge: An Example

    TinyOS Application

  • 7/30/2019 Chapter13 New

    42/44

    Configuration for Surge

    Ti OS

  • 7/30/2019 Chapter13 New

    43/44

    TinyOS

    Resource Interface TinyOS provides a simple but powerful set

    of conventions for dealing with resources.

    Dedicated

    Virtualized

    Shared

    Sh d R

  • 7/30/2019 Chapter13 New

    44/44

    Shared Resource

    Configuration