Real-Time Kernel (Part 1)

Slides:



Advertisements
Similar presentations
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.
Advertisements

Exceptions. Exception Types Exception Handling Vectoring Interrupts Interrupt Handlers Interrupt Priorities Interrupt applications 6-2.
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.
Real-Time Kernels and Operating Systems Basic Issue - Purchase commercial “off-the- shelf” system or custom build one Basic Functions –Task scheduling.
HW/SW Interface Operating Systems Design and Implementation.
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.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
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.
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.
MicroC/OS-II Embedded Systems Design and Implementation.
Exceptions, Interrupts & Traps
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Exception and Interrupt Handling
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.
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
Interrupts Signal that causes the CPU to alter its normal flow on instruction execution ◦ frees CPU from waiting for events ◦ provides control for external.
MICROPROCESSOR INPUT/OUTPUT
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Introduction to Embedded Systems Rabie A. Ramadan 6.
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.
Mutual Exclusion. Readings r Silbershatz: Chapter 6.
Real Time Operating Systems
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
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.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
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.
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.
Outlines  Introduction  Kernel Structure  Porting.
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.
Day 08 Processes.
Day 09 Processes.
Computer System Overview
Lecture 2 Part 2 Process Synchronization
Interrupts.
EE 472 – Embedded Systems Dr. Shwetak Patel.
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:

Real-Time Kernel (Part 1) Operating Systems Design and Implementation

Basic Real-Time Concepts Soft versus Hard real-time soft--as fast as possible but missing deadline is tolerable hard--correct and on time

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

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 Cold start solenoid Air-flow meter Injectors O2 sensor Water temperature sensor ECU Distributor sensors High pressure fuel pump 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 Tasks ISRs

EFI System Critical section (atomic or indivisible) Mutual exclusion? 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 Priority Inheritance 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 Tasks n(21/n - 1) 1 2 0.82 3 0.77 4 0.75 5 0.74 … - 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

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 upb and downb implemented with a test-and-set instruction and busy waiting

Intertask Communiciation 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 PRI 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

Interrupt Service Routine Handler 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) Memory Main Program Save Context 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 Restore Context ISR Vector Table

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