Chapter 4 part 2 Processes and Operating Systems

  • Slides: 27
Download presentation
Chapter 4, part 2: Processes and Operating Systems High Performance Embedded Computing Wayne Wolf

Chapter 4, part 2: Processes and Operating Systems High Performance Embedded Computing Wayne Wolf

Topics n n n Operating systems mechanisms and overhead. Embedded file systems. Concurrent system

Topics n n n Operating systems mechanisms and overhead. Embedded file systems. Concurrent system verification.

General-purpose vs. real-time OS n Schedulers have very different goals in realtime and general-purpose

General-purpose vs. real-time OS n Schedulers have very different goals in realtime and general-purpose operating systems: q q n Real-time scheduler must meet deadlines. General-purpose scheduler tries to distribute time equally among processes. Early real-time operating systems: q q Hunter/Ready OS for microcontrollers was developed in early 1980 s. Mach ran on VAX, etc. , provided real-time characteristics on large platforms.

Memory management n Memory management allows RTOS to run outside applications. q n n

Memory management n Memory management allows RTOS to run outside applications. q n n 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.

Windows CE memory management n n Flat 32 -bit address space. Top 2 GB

Windows CE memory management n n Flat 32 -bit address space. Top 2 GB for kernel. q n Statically mapped. Bottom 2 GB for user processes.

Win. CE user memory space n n n 64 slots of 32 MB each.

Win. CE user memory space n n n 64 slots of 32 MB each. Slot 0 is currently running process. Slots 1 -33 are the processes. q n 32 processes max. Object store, memory mapped files, resource mappings. Slot 63: resource mappings Slots 33 -62: object store, memory mapped files … Slot 3: process Slot 2: process Slot 1: DLLs Slot 0: current process

Mechanisms for real time operation n Two key mechanisms for real time: q q

Mechanisms for real time operation n Two key mechanisms for real time: q q n Interrupt handler is part of the priority system. q n Interrupt handler. Scheduler. Also introduces overhead. Scheduler determines ability to meet deadlines.

Interrupt handling in RTOSs n n Interrupts have priorities set in hardware. These priorities

Interrupt handling in RTOSs n n 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: q q n 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).

Windows CE interrupts n Two types of ISRs: q q Static i. SRs are

Windows CE interrupts n Two types of ISRs: q q Static i. SRs are built into kernel, one-way communication to IST. Installable ISR can be dynamically loaded, uses shared memory to communicate with IST.

Static ISR n Built into the kernel. q n One-way communication from ISR to

Static ISR n Built into the kernel. q n One-way communication from ISR to IST. q n n SHx and MIPS must be written in assembler, limited register availability. Can share a buffer but location must be predefined. Nested ISR support based on CPU, OEM’s initialization. Stack is provided by the kernel.

Installable ISR n n n Can be dynamically loaded into kernel. Loads a C

Installable ISR n n n 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.

Win. CE 4. x interrupts ISR ISR ISH All higher enabled All enabled Except

Win. CE 4. x interrupts ISR ISR ISH All higher enabled All enabled Except ID Enable ID All enabled HW device Set event thread I-ISR OAL kernel IST processing

Operating system overhead n n Rhodes and Wolf studied context switching overhead using simulation.

Operating system overhead n n 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%.

OS overhead results [Rho 99] © 1999 IEEE Computer Society

OS overhead results [Rho 99] © 1999 IEEE Computer Society

Support for scheduling n n n Adomat et al. : RTU scheduling accelerator supported

Support for scheduling n n n 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.

Interprocess communication n IPC often used for large-scale communication in general-purpose systems. Mailboxes are

Interprocess communication n 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 (Qo. S) oriented interprocess communication services.

Power management n Advanced Configuration and Power Management (ACPI) standard defines power management levels:

Power management n Advanced Configuration and Power Management (ACPI) standard defines power management levels: q q q G 3 mechanical off. G 2 soft off. G 1 sleeping. G 0 working. Legacy state.

Stochastic power management n n Benini et al. modeled system and workload as Markov

Stochastic power management n n 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.

Embedded file systems n n n Generally means flash memory storage. Many embedded file

Embedded file systems n n n 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.

Flash memory characteristics n n Flash is electrically erasable. Flash memory wears out during

Flash memory characteristics n n Flash is electrically erasable. Flash memory wears out during writing. q q n Early memories lasted for 10, 000 cycles. Modern memories last for 1 million cycles. Two types of flash: q q q NOR flash operates similar to RAM. NAND is block oriented, gives more transient failures. NAND is faster, may dominate in future.

Wear leveling n n n Flash memory systems move data to equalize wear during

Wear leveling n n n 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.

Virtual mapping n Virtual mapping system stands between file API and physical file system:

Virtual mapping n Virtual mapping system stands between file API and physical file system: q q n 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 address Virtual mapping system Physical address Flash memory

Log-structured file system n Stores log of changes to file, not the original file.

Log-structured file system n Stores log of changes to file, not the original file. q q n n 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.

Verification n System design is often specified using an abstract model. q q n

Verification n System design is often specified using an abstract model. q q n Allows verification before implementation. Eliminates unimportant programming details. Interesting properties: q q A system is live if it moves through the states. A system is in deadlock if components are waiting on each other.

Verification properties n Temporal logic is often used to describe system properties. q n

Verification properties n Temporal logic is often used to describe system properties. q n n n 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.

SPIN n n Model checker for distributed software. Protocols to be verified described in

SPIN n n Model checker for distributed software. Protocols to be verified described in PROMELA language. q n Systems defined over infinite input sequences. Combines depth-first search, automaton reduction, binary decision diagrams, etc. to efficiently search the design space. [Hol 97] © 1997 IEEE

SPIN example [Hol 97] © 1997 IEEE

SPIN example [Hol 97] © 1997 IEEE