HW/SW Interface Operating Systems Design and Implementation.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Chapter 10 Input/Output Organization. Connections between a CPU and an I/O device Types of bus (Figure 10.1) –Address bus –Data bus –Control bus.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
Real-Time Kernels and Operating Systems Basic Issue - Purchase commercial “off-the- shelf” system or custom build one Basic Functions –Task scheduling.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Hardware Support for Operating Systems Sunny Gleason Vivek Uppal COM S 414
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
CHAPTER 9: Input / Output
MicroC/OS-II Embedded Systems Design and Implementation.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
CS-334: Computer Architecture
Introduction to Embedded Systems
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Real-Time Kernel (Part 1)
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
CHAPTER 9: Input / Output
MICROPROCESSOR INPUT/OUTPUT
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
2-1 The critical section –A piece of code which cannot be interrupted during execution Cases of critical sections –Modifying a block of memory shared by.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
Real Time Operating Systems
EEE440 Computer Architecture
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
بسم الله الرحمن الرحيم MEMORY AND I/O.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
CHAPTER 7 CONCURRENT SOFTWARE Copyright © 2000, Daniel W. Lewis. All Rights Reserved.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Chapter 3 System Buses.  Hardwired systems are inflexible  General purpose hardware can do different tasks, given correct control signals  Instead.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
2-1 Chapter 2 Real-Time Systems Concepts. 2-2 Foreground/Background Systems BackgroundForeground ISR Time Code execution application consists of an infinite.
Big Picture Lab 4 Operating Systems C Andras Moritz
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Microprocessor Systems Design I
Topics Covered What is Real Time Operating System (RTOS)
Computer Architecture
Interrupts In 8085 and 8086.
Computer System Overview
Interrupts.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

HW/SW Interface Operating Systems Design and Implementation

Foreground/Background Systems Often referred to as super-loops Background (task level) Foreground (interrupt level) ISR Handle Asynchronous Events Infinite loop calling modules Interruption occurred

Interrupt Service Routines Handle critical operations –can take longer than they should –make data available for background routines processing of such information is referred to task-level response

Example: EFI System (Electronic Fuel Injection) What are the components? Throttle Body Air-flow meter Injectors ECU Distributor sensors Cold start solenoid High pressure fuel pump Water temperature sensor O2 sensor manifold sensor

EFI System How does it work? –fundamentally, it manages three necessities to start and maintain operation of a gasoline engine fuel spark air

EFI System What happen to the EFI system when you start a car? What happen to the EFI system when you drive a car?

Dissecting EFI System TasksISRs

EFI System Critical section (atomic or indivisible) –any possible critical regions in our tasks? Mutual exclusion? Reentrant code? –functions can be used by multiple tasks without causing data corruption Priority inversion problem?

Priority Inversion Assume task 3 has lower priority than task 1. –Task 1 is doing I/O so Task 3 gets to run –Task 3 is in the middle of accessing a shared resource (obtain semaphore) –Task 1 finishes so it preempts Task 3 –Task 1 wants to access the same resource but can’t since Task 3 has the semaphore

Priority Inversion In this scenario, the priority of Task 1 is reduced to that of Task 3. What is a good solution? Priority Inheritance

Priority Inversion Priority Inheritance –Task 1 is doing I/O so Task 3 gets to run –Task 3 is in the middle of accessing a shared resource (obtain semaphore) –Task 1 finishes so it preempts Task 3 –Task 1 wants to access the same resource but can’t since Task 3 has the semaphore; thus the kernel raises the priority of Task 3 to the same as Task 1 –Task 3 gets to finish and releases the resource. The priority is reset to the original value –Task 1 is selected if it still has the highest priority

Assigning Task Priority Rate monotonic scheduling –tasks with the highest rate of execution are given the highest priority Assume all tasks are periodic Tasks do not synchronize with another, share resources, and exchange data Preemptive scheduling is used

Assigning Task Priority Number of Tasksn(2 1/n - 1) … -0.69

Providing Mutual Exclusion Disabling interrupt Test and Set operation –hardware support (TSL operation) Disabling scheduler Semaphores –how is semaphore implemented?

Disabling Interrupt X86 –CLI (disable interrupt) –STI (enable interrupt)

Busy Waiting

Semaphore Is a type that has a counter and a delay queue –require OS support as processes in the delay queue are blocked –implementation often requires other primitive support (disabling interrupt, etc.)

Semaphore assumes the existence of binary semaphore operations up b and down b implemented with a test-and-set instruction and busy waiting

Intertask Communication Message mailbox Message queues –often use to process interrupt

Interrupts A hardware mechanism used to notify the CPU that asynchronous events have occurred Upon completion, the programs return to: –background for a foreground/background system –the interrupted task for non-premptive kernel –the higest priority task ready to run for premptive kernel

Example: Interrupt in NIOS IE bit to enabling interrupt IPRI bits for priority MISC bits for interrupt control

Source of Exceptions (NIOS) External Hardware interrupt Sources –External logic for producing the 6-bits interrupt number & asserting the IRQ input pin is automatically generated by the SOPC builder and is included in the Peripheral Bus Module (PBM). Internal Exception Sources –2 sources of internal exceptions Register window-overflow, Register window-underflow Direct Software Exceptions –Software can request that control be transferred to an exception handler by issuing a TRAP instruction.

External Hardware Interrupts Active-high interrupt signal: irq –Level sensitive –Sampled synchronously at the rising edge of Nios clock –Should stay asserted until the interrupt is acknowledged by software 6-bit Input Interrupt Number: irq_number[5:0] –Identifies the highest priority interrupt currently requested Highest priority = 0 (irq #0 to #15 are reserved) Lowest priority = 63

External Hardware Interrupts Nios will process the indicated exception if –IE= 1 – i.e. external interrupts & internal exceptions are enabled, AND –The interrupt number is smaller (lower or equal) than the IPRI field value

Internal Hardware Interrupts

Interrupt Service Routine Handler nr_installuserisr nr_installuserisr(int trapNumber, void *ISRProcedure, int context) trapNumber is the exception number to be associated with a service routine ISRProcedure is a routine which has a prototype of typedef void (*Nios_isrhandlerproc) (int context); context is a value that will be passed to the routine specified by isrProcedure

ISR Handler This routine installs an interrupt service routine for a specific exception number If nr_installuserisr() is used to set up the exception handler, then the exception handler can be an ordinary C routine

ISR Process Interrupt occurs Current state is saved (Context) ISR address is retrieved from the vector table based on the interrupt number Jump to ISR routine Runs to completion Context is restored Program resumes Memory Vector Table ISR Main Program Save Context Restore Context

ISR Implementation Specify your # IRQ Declare your IRQ subroutines Update the ISR vector table Write your IRQ Subroutine ROM instruction RAM 63 Vector Table 0xFFFF … 0xFF0F 0xFF0E … 0xFFC0

Interrupt Example UART (Universal Asynchronous Receiver Transmitter) –Transferring data between processor and I/O devices –Handle one 8-bit data at a time Transfer in parallel between UART and Processor and in bit-serial between I/O device and UART

JTAG UART Used to provide a connection between a Nios II processor and the host computer connected to the DE 2 board

JTAG UART Data and control registers accessed by Nios II as memory locations # of char remaining in the read FIFO read valid read/write data from FIFOs read/write interrupt enable read/write/JTAG pending available space in write FIFO

JTAG UART

Polling vs. Interrupt