Embedded Real-Time Systems Processing interrupts Lecturer Department University.

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

Real-Time Kernels and Operating Systems Basic Issue - Purchase commercial “off-the- shelf” system or custom build one Basic Functions –Task scheduling.
ECE 526 – Network Processing Systems Design Software-based Protocol Processing Chapter 7: D. E. Comer.
Process Description and Control
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
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.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
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.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
CHAPTER 9: Input / Output
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Interrupts  Interrupt is a process where an external device can get the attention of the microprocessor.  The process starts from the I/O device  The.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Interrupts Signal that causes the CPU to alter its normal flow on instruction execution ◦ frees CPU from waiting for events ◦ provides control for external.
CHAPTER 9: Input / Output
MICROPROCESSOR INPUT/OUTPUT
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Tami Meredith, Ph.D. CSCI  Devices need CPU access  E.g., NIC has a full buffer it needs to empty  These device needs are often asynchronous.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
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.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
بسم الله الرحمن الرحيم MEMORY AND I/O.
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.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Embedded Real-Time Systems
WORKING OF SCHEDULER IN OS
Processes and threads.
Process Management Process Concept Why only the global variables?
Topics Covered What is Real Time Operating System (RTOS)
OPERATING SYSTEMS CS3502 Fall 2017
Anton Burtsev February, 2017
Computer Architecture
Structure of Processes
Direct Memory Access Disk and Network transfers: awkward timing:
Process Description and Control
Process Description and Control
Architectural Support for OS
Process Description and Control
Process Description and Control
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Process Description and Control
Process Description and Control
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Process Description and Control
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Architectural Support for OS
COMP3221: Microprocessors and Embedded Systems
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Embedded Real-Time Systems Processing interrupts Lecturer Department University

2 Outline Interrupt processing in real-time systems Limitations of ISRs ISR-to-task communication

3 A bit of history … Interrupt – a signal from hardware indicating need for attention Introduced to avoid wasting processor ’ s time in polling loops Commonly used technique for computer multi- tasking

4 Interrupts processing The CPU interrupts execution of the current tasks and transfers control to the corresponding interrupt service routine (ISR) hardware interrupt controller CPU ISR Current task Interrupt signal

5 Classification Synchronous – predictable, occur at known times (e.g. system clock) Asynchronous – can occur at any time, when a device needs attention Software interrupts – generated by CPU executing an instruction Maskable – can be ignored Non-maskable – cannot be ignored (usually notify about serious system problem)

6 Interrupt service routines Reacts on the interrupt signals from the hardware performing necessary hardware management operations data exchange with user application tasks (I/O) notification of the application tasks about the external events Important part of a real-time OS: task scheduling disk I/O networking other examples …

7 Interrupt processing in RTOS ISRs block the highest priority task – interferes with the task scheduler, affects real- time behaviour Solution – defer interaction with hardware acknowledge interrupt queue work for a normal task (e.g. a device driver task) ISR Driver task Work queue Interrupt call Ack./disable

8 Interrupt processing in RTOS (contd.) All ISRs are executed in a special context: outside of any task ’ s context interrupt handling involves no context switch fast response Downside: limits what ISRs can do (since they have no task context) more on this later …

9 Connecting ISR code to interrupts intConnect (vector, function, parameter) connects a C function to an interrupt vector – the interrupt vector (interrupt number) function – the ISR parameter – optional ISR parameter (e.g. using the same ISR code for handling different interrupt sources in a similar way) Interrupt Vector Table: maps interrupt vector numbers to the corresponding ISR addresses “ vector ” above specifies the offset in the interrupt vector table

10 Interrupt vector table Details vary for different CPU architectures, but the basic idea is the same: hardware interrupt signals are mapped onto entries in the IVT when interrupt occurs, the CPU uses the corresponding IVT entry to locate the ISR … … interrupt vector Hardware interrupt levels n n+1 n+2

11 Using C functions as ISRs Cannot vector directly to C functions – need to save the state of the interrupted task! RTOS builds a wrapper around ISR

12 Interrupt stack Special memory space storing the state of the CPU for the interrupted task allocating dynamic variables used by the ISR code Interrupt stack in RTOS use the same stack for all ISRs (where allowed by the CPU architecture) Where architecture does not support special ISR stack (e.g. Intel x86), use the stack of the interrupted task What is a potential problem here? How to address it?

13 Interrupt calls (summary)

14 Limitations of ISRs ISRs do not run in a regular task context: no task to block data normally stored in the task control block is unavailable Limitations: any calls requiring a task control block cannot be used (so, inspect details of a call in question!) cannot invoke routines that might cause the caller to block – no task to block, cannot block the OS kernel! e.g. cannot take semaphore (might block)

15 Limitation of ISRs (contd.) cannot call malloc() or free() – both of these take a semaphore (WHY?) cannot call routines that call malloc() or free() e.g. any creation or deletion routines. must not perform I/O through RTOS drivers: might block some require task control block to access file descriptors (e.g. the standard input/output/error)

16 Interrupt-to-task communication Once interrupt is detected and processed by the ISR, we need to inform the appropriate task about the external event The idea is the same as for inter-task communication … Tasks should be able to wait until an event occurs … except need to take into account the limitations of ISRs hardware ISR Application task Interrupt ?

17 Interrupt-to-task communication Shared memory ISR writes data into shared memory, e.g. set a flag value Semaphores ISR gives a semaphore. The task can try to take it. If there were no interrupt, the task will be blocked until the event occurs. Message queues ISR can send a message for a task to receive. Remember to use NO_WAIT though! If the queue is full, the message is discarded.

18 Debugging ISRs RTOS supplies a logging facility a logging task prints text messages to the system console specifically designed so that ISRs could use it common way to print messages from ISR... /* log a message */ msgLog(“some message”);... /* get messages from queue */... printf(msg);... message queue ISR:Logging task: Remember tLogTask?

19 Summary Interrupts allow computer systems to react on events from hardware while efficiently using CPU resources In real-time systems, can interfere with task scheduling. Solution – do minimum work in ISR, defer processing for a driver task Limitations on what you can do in ISRs