J.SUDARSHANREDDY
Chapter 4, part 2: Processes
and Operating Systems
High Performance Embedded
Computing
Wayne Wolf
1/25/2015
J.SUDARSHANREDDY
Topics
 Operating systems mechanisms and
overhead.
 Embedded file systems.
 Concurrent system verification.
1/25/2015
J.SUDARSHANREDDY
General-purpose vs. real-time OS
 Schedulers have very different goals in real-
time and general-purpose operating systems:
 Real-time scheduler must meet deadlines.
 General-purpose scheduler tries to distribute time
equally among processes.
 Early real-time operating systems:
 Hunter/Ready OS for microcontrollers was
developed in early 1980s.
 Mach ran on VAX, etc., provided real-time
characteristics on large platforms.
1/25/2015
J.SUDARSHANREDDY
Memory management
 Memory management allows RTOS to run
outside applications.
 Cell phones run downloaded, user-installed
programs.
 Memory management helps the RTOS
manage a large virtual address space.
 Flash may be used as a paging device.
1/25/2015
J.SUDARSHANREDDY
Windows CE memory management
 Flat 32-bit address space.
 Top 2 GB for kernel.
 Statically mapped.
 Bottom 2 GB for user processes.
1/25/2015
J.SUDARSHANREDDY
WinCE user memory space
 64 slots of 32 MB each.
 Slot 0 is currently
running process.
 Slots 1-33 are the
processes.
 32 processes max.
 Object store, memory
mapped files, resource
mappings.
Slot 0: current process
Slot 1: DLLs
Slot 2: process
Slot 3: process
…
Slots 33-62: object store,
memory mapped files
Slot 63: resource mappings
1/25/2015
J.SUDARSHANREDDY
Mechanisms for real time operation
 Two key mechanisms for real time:
 Interrupt handler.
 Scheduler.
 Interrupt handler is part of the priority system.
 Also introduces overhead.
 Scheduler determines ability to meet
deadlines.
1/25/2015
J.SUDARSHANREDDY
Interrupt handling in RTOSs
 Interrupts have priorities set in hardware.
 These priorities supersede process priorities of the
processes.
 We want to spend as little time as possible in the
hardware priority space to avoid interfering with the
scheduler.
 Two layers of processing:
 Interrupt service routine (ISR) is dispatched by hardware.
 Interrupt service thread (IST) is a process.
 Spend as little time in the ISR (hardware priorities),
do most of the work in the IST (scheduler priorities).
1/25/2015
J.SUDARSHANREDDY
Windows CE interrupts
 Two types of ISRs:
 Static iSRs are built into kernel, one-way
communication to IST.
 Installable ISR can be dynamically loaded, uses
shared memory to communicate with IST.
1/25/2015
J.SUDARSHANREDDY
Static ISR
 Built into the kernel.
 SHx and MIPS must be written in assembler, limited
register availability.
 One-way communication from ISR to IST.
 Can share a buffer but location must be predefined.
 Nested ISR support based on CPU, OEM’s
initialization.
 Stack is provided by the kernel.
1/25/2015
J.SUDARSHANREDDY
Installable ISR
 Can be dynamically loaded into kernel.
 Loads a C DLL.
 Can use shared memory for communication.
 ISRs are processed in the order they were
installed.
 Limited stack size.
1/25/2015
J.SUDARSHANREDDY
WinCE 4.x interrupts
All higher
enabled
HWkernelOALI-ISRthread
All enabled
Except ID
All enabled
ISH Set event Enable ID
ISR ISR
ISR ISR
IST processing
device
1/25/2015
J.SUDARSHANREDDY
Operating system overhead
 Rhodes and Wolf studied context switching
overhead using simulation.
 Two-CPU system with bus.
 100 random task graphs.
 Varying amounts of slack: none, 10%, 20%,
40%.
1/25/2015
J.SUDARSHANREDDY
OS overhead results
[Rho99] © 1999 IEEE Computer Society1/25/2015
J.SUDARSHANREDDY
Support for scheduling
 Adomat et al.: RTU scheduling accelerator
supported up to 3 CPUs, evaluated readiness
and priority.
 Burleson et al.: Spring scheduling accelerator
supported dynamically appearing tasks.
 Kohout et al.: RTM scheduler used tree
network to sort processes for scheduling.
1/25/2015
J.SUDARSHANREDDY
Interprocess communication
 IPC often used for large-scale communication
in general-purpose systems.
 Mailboxes are specialized memories, used
for small, fast transfers.
 Multimedia systems can be supported by
quality-of-service (QoS) oriented interprocess
communication services.
1/25/2015
J.SUDARSHANREDDY
Power management
 Advanced Configuration and Power
Management (ACPI) standard defines power
management levels:
 G3 mechanical off.
 G2 soft off.
 G1 sleeping.
 G0 working.
 Legacy state.
1/25/2015
J.SUDARSHANREDDY
Stochastic power management
 Benini et al. modeled system and workload
as Markov chains.
 Service requester models workload as a
sequence of service requests.
 Service provider is a Markov chain whose
probabilities are controlled by power manager
commands.
 A linear program can find a minimum-power
policy that meets performance constraints.
1/25/2015
J.SUDARSHANREDDY
Embedded file systems
 Generally means flash memory storage.
 Many embedded file systems need to be
compatible with PCs.
 Some file systems are primarily for reading,
others for reading and writing.
1/25/2015
J.SUDARSHANREDDY
Flash memory characteristics
 Flash is electrically erasable.
 Flash memory wears out during writing.
 Early memories lasted for 10,000 cycles.
 Modern memories last for 1 million cycles.
 Two types of flash:
 NOR flash operates similar to RAM.
 NAND is block oriented, gives more transient
failures.
 NAND is faster, may dominate in future.
1/25/2015
J.SUDARSHANREDDY
Wear leveling
 Flash memory systems move data to
equalize wear during writes.
 File allocation table gets the most writes---
must be moved as well.
 Formatting avoids multiple writes to file
allocation table.
1/25/2015
J.SUDARSHANREDDY
Virtual mapping
 Virtual mapping system
stands between file API and
physical file system:
 Schedules erasures.
 Consolidates data.
 Identifies bad blocks.
 Moves data for wear
leveling.
 Virtual mapping system
keeps a table to translate
virtual to physical
addresses.
File system
Virtual mapping system
Flash memory
Virtual address
Physical address
1/25/2015
J.SUDARSHANREDDY
Log-structured file system
 Stores log of changes to file, not the original
file.
 Also known as journaling.
 Developed for general-purpose systems, useful
for flash.
 Journaling Flash File System (JFFS)
maintains consistency during power losses.
 Yet Another Flash Filing System (YAFFS) is
log-structured file system for NAND flash.
1/25/2015
J.SUDARSHANREDDY
Verification
 System design is often specified using an
abstract model.
 Allows verification before implementation.
 Eliminates unimportant programming details.
 Interesting properties:
 A system is live if it moves through the states.
 A system is in deadlock if components are waiting
on each other.
1/25/2015
J.SUDARSHANREDDY
Verification properties
 Temporal logic is often used to describe
system properties.
 Quantify over time and values.
 Linear-time temporal logic models one
timeline.
 Branching-time temporal logic models a tree
of timelines.
 Example: []f(x) => f(x) is true at every time.
1/25/2015
J.SUDARSHANREDDY
SPIN
 Model checker for
distributed software.
 Protocols to be verified
described in PROMELA
language.
 Systems defined over
infinite input sequences.
 Combines depth-first
search, automaton
reduction, binary decision
diagrams, etc. to efficiently
search the design space.
[Hol97] © 1997 IEEE1/25/2015
J.SUDARSHANREDDY
SPIN example
[Hol97] © 1997 IEEE1/25/2015

WINDOWS-CE

  • 1.
    J.SUDARSHANREDDY Chapter 4, part2: Processes and Operating Systems High Performance Embedded Computing Wayne Wolf 1/25/2015
  • 2.
    J.SUDARSHANREDDY Topics  Operating systemsmechanisms and overhead.  Embedded file systems.  Concurrent system verification. 1/25/2015
  • 3.
    J.SUDARSHANREDDY General-purpose vs. real-timeOS  Schedulers have very different goals in real- time and general-purpose operating systems:  Real-time scheduler must meet deadlines.  General-purpose scheduler tries to distribute time equally among processes.  Early real-time operating systems:  Hunter/Ready OS for microcontrollers was developed in early 1980s.  Mach ran on VAX, etc., provided real-time characteristics on large platforms. 1/25/2015
  • 4.
    J.SUDARSHANREDDY Memory management  Memorymanagement allows RTOS to run outside applications.  Cell phones run downloaded, user-installed programs.  Memory management helps the RTOS manage a large virtual address space.  Flash may be used as a paging device. 1/25/2015
  • 5.
    J.SUDARSHANREDDY Windows CE memorymanagement  Flat 32-bit address space.  Top 2 GB for kernel.  Statically mapped.  Bottom 2 GB for user processes. 1/25/2015
  • 6.
    J.SUDARSHANREDDY WinCE user memoryspace  64 slots of 32 MB each.  Slot 0 is currently running process.  Slots 1-33 are the processes.  32 processes max.  Object store, memory mapped files, resource mappings. Slot 0: current process Slot 1: DLLs Slot 2: process Slot 3: process … Slots 33-62: object store, memory mapped files Slot 63: resource mappings 1/25/2015
  • 7.
    J.SUDARSHANREDDY Mechanisms for realtime operation  Two key mechanisms for real time:  Interrupt handler.  Scheduler.  Interrupt handler is part of the priority system.  Also introduces overhead.  Scheduler determines ability to meet deadlines. 1/25/2015
  • 8.
    J.SUDARSHANREDDY Interrupt handling inRTOSs  Interrupts have priorities set in hardware.  These priorities supersede process priorities of the processes.  We want to spend as little time as possible in the hardware priority space to avoid interfering with the scheduler.  Two layers of processing:  Interrupt service routine (ISR) is dispatched by hardware.  Interrupt service thread (IST) is a process.  Spend as little time in the ISR (hardware priorities), do most of the work in the IST (scheduler priorities). 1/25/2015
  • 9.
    J.SUDARSHANREDDY Windows CE interrupts Two types of ISRs:  Static iSRs are built into kernel, one-way communication to IST.  Installable ISR can be dynamically loaded, uses shared memory to communicate with IST. 1/25/2015
  • 10.
    J.SUDARSHANREDDY Static ISR  Builtinto the kernel.  SHx and MIPS must be written in assembler, limited register availability.  One-way communication from ISR to IST.  Can share a buffer but location must be predefined.  Nested ISR support based on CPU, OEM’s initialization.  Stack is provided by the kernel. 1/25/2015
  • 11.
    J.SUDARSHANREDDY Installable ISR  Canbe dynamically loaded into kernel.  Loads a C DLL.  Can use shared memory for communication.  ISRs are processed in the order they were installed.  Limited stack size. 1/25/2015
  • 12.
    J.SUDARSHANREDDY WinCE 4.x interrupts Allhigher enabled HWkernelOALI-ISRthread All enabled Except ID All enabled ISH Set event Enable ID ISR ISR ISR ISR IST processing device 1/25/2015
  • 13.
    J.SUDARSHANREDDY Operating system overhead Rhodes and Wolf studied context switching overhead using simulation.  Two-CPU system with bus.  100 random task graphs.  Varying amounts of slack: none, 10%, 20%, 40%. 1/25/2015
  • 14.
    J.SUDARSHANREDDY OS overhead results [Rho99]© 1999 IEEE Computer Society1/25/2015
  • 15.
    J.SUDARSHANREDDY Support for scheduling Adomat et al.: RTU scheduling accelerator supported up to 3 CPUs, evaluated readiness and priority.  Burleson et al.: Spring scheduling accelerator supported dynamically appearing tasks.  Kohout et al.: RTM scheduler used tree network to sort processes for scheduling. 1/25/2015
  • 16.
    J.SUDARSHANREDDY Interprocess communication  IPCoften used for large-scale communication in general-purpose systems.  Mailboxes are specialized memories, used for small, fast transfers.  Multimedia systems can be supported by quality-of-service (QoS) oriented interprocess communication services. 1/25/2015
  • 17.
    J.SUDARSHANREDDY Power management  AdvancedConfiguration and Power Management (ACPI) standard defines power management levels:  G3 mechanical off.  G2 soft off.  G1 sleeping.  G0 working.  Legacy state. 1/25/2015
  • 18.
    J.SUDARSHANREDDY Stochastic power management Benini et al. modeled system and workload as Markov chains.  Service requester models workload as a sequence of service requests.  Service provider is a Markov chain whose probabilities are controlled by power manager commands.  A linear program can find a minimum-power policy that meets performance constraints. 1/25/2015
  • 19.
    J.SUDARSHANREDDY Embedded file systems Generally means flash memory storage.  Many embedded file systems need to be compatible with PCs.  Some file systems are primarily for reading, others for reading and writing. 1/25/2015
  • 20.
    J.SUDARSHANREDDY Flash memory characteristics Flash is electrically erasable.  Flash memory wears out during writing.  Early memories lasted for 10,000 cycles.  Modern memories last for 1 million cycles.  Two types of flash:  NOR flash operates similar to RAM.  NAND is block oriented, gives more transient failures.  NAND is faster, may dominate in future. 1/25/2015
  • 21.
    J.SUDARSHANREDDY Wear leveling  Flashmemory systems move data to equalize wear during writes.  File allocation table gets the most writes--- must be moved as well.  Formatting avoids multiple writes to file allocation table. 1/25/2015
  • 22.
    J.SUDARSHANREDDY Virtual mapping  Virtualmapping system stands between file API and physical file system:  Schedules erasures.  Consolidates data.  Identifies bad blocks.  Moves data for wear leveling.  Virtual mapping system keeps a table to translate virtual to physical addresses. File system Virtual mapping system Flash memory Virtual address Physical address 1/25/2015
  • 23.
    J.SUDARSHANREDDY Log-structured file system Stores log of changes to file, not the original file.  Also known as journaling.  Developed for general-purpose systems, useful for flash.  Journaling Flash File System (JFFS) maintains consistency during power losses.  Yet Another Flash Filing System (YAFFS) is log-structured file system for NAND flash. 1/25/2015
  • 24.
    J.SUDARSHANREDDY Verification  System designis often specified using an abstract model.  Allows verification before implementation.  Eliminates unimportant programming details.  Interesting properties:  A system is live if it moves through the states.  A system is in deadlock if components are waiting on each other. 1/25/2015
  • 25.
    J.SUDARSHANREDDY Verification properties  Temporallogic is often used to describe system properties.  Quantify over time and values.  Linear-time temporal logic models one timeline.  Branching-time temporal logic models a tree of timelines.  Example: []f(x) => f(x) is true at every time. 1/25/2015
  • 26.
    J.SUDARSHANREDDY SPIN  Model checkerfor distributed software.  Protocols to be verified described in PROMELA language.  Systems defined over infinite input sequences.  Combines depth-first search, automaton reduction, binary decision diagrams, etc. to efficiently search the design space. [Hol97] © 1997 IEEE1/25/2015
  • 27.