CSC227: Operating Systems Fall Chapter 1 INTERRUPTS. Dr. Soha S. Zaghloul

Similar documents
3.1 Introduction. Computers perform operations concurrently

Input / Output. School of Computer Science G51CSA

Hardware OS & OS- Application interface

INPUT/OUTPUT ORGANIZATION

INPUT/OUTPUT ORGANIZATION

ECE 341. Lecture # 19


Interrupts Peter Rounce

Interrupts Peter Rounce - room 6.18

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Computer Architecture CS 355 Busses & I/O System

The control of I/O devices is a major concern for OS designers

5.b Principles of I/O Hardware CPU-I/O communication

Windows Interrupts

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

There are different characteristics for exceptions. They are as follows:

Unit 5. Memory and I/O System

I/O Systems. Jo, Heeseung

Control unit. Input/output devices provide a means for us to make use of a computer system. Computer System. Computer.

Input Output (IO) Management

PC Interrupt Structure and 8259 DMA Controllers

Last class: Today: Course administration OS definition, some history. Background on Computer Architecture

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

INPUT/OUTPUT ORGANIZATION

I/O Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

THE CPU SPENDS ALMOST ALL of its time fetching instructions from memory

An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal)

Computer Organization ECE514. Chapter 5 Input/Output (9hrs)

CSE 120 Principles of Operating Systems

An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal)

CSC 2405: Computer Systems II

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Exception Handling. Precise Exception Handling. Exception Types. Exception Handling Terminology

Unit 3 and Unit 4: Chapter 4 INPUT/OUTPUT ORGANIZATION

CS 550 Operating Systems Spring Interrupt

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks

INTERRUPTS in microprocessor systems

Resource Management IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

EE458 - Embedded Systems Exceptions and Interrupts

Lec 22: Interrupts. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

Chapter 3. Top Level View of Computer Function and Interconnection. Yonsei University

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

CPS104 Computer Organization and Programming Lecture 17: Interrupts and Exceptions. Interrupts Exceptions and Traps. Visualizing an Interrupt

CS 201. Exceptions and Processes. Gerson Robboy Portland State University

IT 540 Operating Systems ECE519 Advanced Operating Systems

Chapter 1 Computer System Overview

Lecture 2: Architectural Support for OSes

CSE 153 Design of Operating Systems Fall 18

ECE 485/585 Microprocessor System Design

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

CSCE Introduction to Computer Systems Spring 2019

CS370 Operating Systems

Chapter 3 - Top Level View of Computer Function

Chapter 13: I/O Systems

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Chapter 13: I/O Systems

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

CSE 120 Principles of Operating Systems

Announcement. Exercise #2 will be out today. Due date is next Monday

Virtual Machines & the OS Kernel

Chapter 5 Input/Output Organization. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Silberschatz and Galvin Chapter 12

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

For more notes of DAE

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

Chapter 13: I/O Systems

Top-Level View of Computer Organization

操作系统概念 13. I/O Systems

Q.1 Explain Computer s Basic Elements

Process Scheduling Queues

CS330: Operating System and Lab. (Spring 2006) I/O Systems

Interrupt is a process where an external device can get the attention of the microprocessor. Interrupts can be classified into two types:

Anne Bracy CS 3410 Computer Science Cornell University

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

Architectural Support for Operating Systems

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

Syscalls, exceptions, and interrupts, oh my!

Sistemi in Tempo Reale

Yielding, General Switching. November Winter Term 2008/2009 Gerd Liefländer Universität Karlsruhe (TH), System Architecture Group

Input/Output Interfaces: Ch

Digital Design Laboratory Lecture 6 I/O

Reset, Interrupts, Exceptions, and Break ECE 3534

Programmed I/O Interrupt-Driven I/O Direct Memory Access (DMA) I/O Processors. 10/12/2017 Input/Output Systems and Peripheral Devices (02-2)

1. Background. 2. Demand Paging

Virtual Machines & the OS Kernel

Systems Programming and Computer Architecture ( ) Timothy Roscoe

INPUT-OUTPUT ORGANIZATION

18-349: Introduction to Embedded Real-Time Systems

Introduction to Embedded Systems. Lab Logistics

Operating System Concepts

What are Exceptions? EE 457 Unit 8. Exception Processing. Exception Examples 1. Exceptions What Happens When Things Go Wrong

eaymanelshenawy.wordpress.com

CSE 153 Design of Operating Systems

These three counters can be programmed for either binary or BCD count.

Computer System Overview

Computer System Overview OPERATING SYSTEM TOP-LEVEL COMPONENTS. Simplified view: Operating Systems. Slide 1. Slide /S2. Slide 2.

Transcription:

CSC227: Operating Systems Fall 2016 Chapter 1 INTERRUPTS Dr. Soha S. Zaghloul

LAYOUT 1.3 Devices Controlling Techniques 1.3.1 Polling 1.3.2 Interrupts H/W Interrupts Interrupt Controller Process State Interrupt Vector Manipulation Example Interrupt Timeline S/W Interrupts Exception classes Dr. Soha S. Zaghloul 2

1.3 Devices Controlling Techniques Device Controller Each I/O unit consists of two components: a mechanical one and an electronic one. The electronic one is called the device controller or device adapter. On personal computers, it often takes the form of a printed circuit card that can be inserted into an expansion slot on the mainboard. Slots Device Controller (Adapter) Motherboard (mainboard) Dr. Soha S. Zaghloul 3

1.3 Devices Controlling Techniques Device Driver The controller card usually has a connector into which a cable leading to the device itself can be plugged. The OS deals with device controller (H/W) rather than the device itself through the corresponding device driver (S/W). Each controller has a few registers. Based on the contents of these registers, the OS can command the device to perform a specific action such as deliver data, accept data, switch on/off, etc Also, the OS learns the state of the device from these registers. In addition to the registers, a controller contains data buffers that the OS can read/write. Dr. Soha S. Zaghloul 4

1.3 Devices Controlling Techniques Devices Controlling Techniques It is important for the OS to recognize and manipulate the status of each device. The status of a device includes the following information: Is it correctly connected or not? Does it work or not? Is it busy or available? The OS keeps track of the statuses of all connected devices using a device-status table stored in memory. Two techniques are applied for this purpose: Polling Interrupt Dr. Soha S. Zaghloul 5

1.3.1 Polling Polling: ~ Target: In order for the CPU to recognize the status of each connected device, a communication should take place between both. ~ Concept: The CPU repeatedly requests from each device its current status. ~ Definition: The CPU sends electrical signals regularly to each connected device asking about its current status. The device emits another signal to respond to each signal sent by the CPU. ~ Disadvantages: * This causes an overhead on the CPU * The CPU stays idle waste of resources * The mechanism is slow * Increases the complexity of the computer system What is your status? What is your status? Device 1 CPU Device 2 I am busy I am busy Interrupts eliminate the need for a processor to repeatedly poll devices. Dr. Soha S. Zaghloul 6

Interrupts ~ Definition: An interrupt is an electrical signal emitted by the hardware or software to the processor indicating an event that needs immediate attention. ~ Target: Interrupts allow the OS to take control of the processor to manage system resources. ~ Concept: An interrupt alerts the processor to a high-priority condition requiring the interruption of the current code that the CPU is executing. As soon as the CPU receives an interrupt, the following steps are performed: (1) The processor suspends its current activity. (2) The processor saves its state. (3) The processor calls the Interrupt Handler (IH), sometimes called Interrupt Service Routine (ISR), to handle the event. The Interrupt Handler (IH) or Interrupt Service Routine (ISR) is a relatively small program (procedure). It is part of the OS. There are many types of interrupts. Each type of interrupt calls the corresponding Interrupt Handler. Dr. Soha S. Zaghloul 7

Interrupt Classes Hardware Interrupts Software Interrupts Dr. Soha S. Zaghloul 8

Interrupt Classes H/W Interrupts ~ Emitted by a device to indicate that it requires attention from the OS. ~ Implemented using electronic signals sent from an internal/external device. ~ For example, pressing a key on the keyboard triggers an interrupt that causes the processor to read the keystroke. ~ May occur in the middle of instruction execution. ~ Asynchronous: changes immediately does not wait for the fall/rise of a clock cycle. ~ Requires special care in programming. ~ The act of initiating a hardware interrupt is known as an Interrupt Request (IRQ). ~ The number of H/W interrupts is limited by the number of IRQ lines. Dr. Soha S. Zaghloul 9

H/W Interrupts Interrupt Controller An interrupt line is an electrical connection between the mainboard and the CPU. Each device has a controller that is responsible to activate the interrupt line when necessary (ie. when a status changes) to inform the CPU that an event has occurred. The CPU is provided with an interrupt controller that sorts the received requests based on their priority. Important interrupts are therefore serviced first. The rest of interrupts are queued and serviced after higher-priority ones. Dr. Soha S. Zaghloul 10

Hardware Interrupts Process State The paused process (program) resumes after the CPU handles the current interrupt. In order to continue a process after being paused, some information should be saved. Examples of such information include: ~ where did the execution stop (instruction address) ~ the values of data generated during process execution: these are saved in the registers. ~ and others These information are known as the process state. The process state is stored in the Process Control Block (PCB). Each process has its own (PCB). Dr. Soha S. Zaghloul 11

H/W Interrupts Interrupt Vector Each type of interrupt is assigned a unique value that the CPU uses as an index into the interrupt vector. The interrupt vector is an array of pointers to the memory addresses of all available interrupt handlers. The interrupt vector is loaded in a protected area of the memory, so that it cannot be erased or modified inadvertently. Dr. Soha S. Zaghloul 12

H/W Interrupts Manipulation Step 1: When the status of a device changes, it activates the interrupt line to inform the CPU about the event. Step 2: As soon as the CPU receives the signal through the interrupt line, it completes execution of the current instruction then pauses the execution of the current process (program). Step 3: The CPU saves the state of the paused process. Step 4: The CPU transfers control to the appropriate interrupt handler. Step 5: The interrupt handler performs appropriate actions based on the type of interrupt. Step 6: After the interrupt handler completes execution, the state of the previously interrupted process is restored. Dr. Soha S. Zaghloul 13

H/W Interrupts - Example A time-out is set to a specific time. When the time elapses the clock sends an interrupt. Processor Control Process P1 is executing clock Time out: Send Interrupt to CPU Interrupt line active Interrupt Vector (in memory) Processor Control OS Control Device P1 state saved to temporary location in memory Interrupt Handler is executing Restore state of P1 Process P1 resumes execution Dr. Soha S. Zaghloul 14

H/W Interrupts - Interrupt Timeline P1 sends a print and continues execution P1 executes P1 paused, state saved, control transferred to OS Printer idle IH completes, P1 state restored, P1 resumed Printer busy Printing done IL activated IL = Interrupt Line IH = Interrupt Handler Note how the H/W-generated interrupts are asynchronous; ie. Changes do not wait for the rise/fall of the clock. Dr. Soha S. Zaghloul 15

Interrupt Classes S/W Interrupts ~ May occur unintentionally due to an error that cannot be handled by the CPU: this is known as exception or trap. ~ For example, an exception is thrown when the program attempts to: * Divide by zero. * Access a protected memory area. * Access an out-of-memory address. ~ In such cases, the OS decides to abort (end) the program. ~ S/W Interrupts may also be intentionally caused by a special instruction in the instruction set. ~ Examples of intentionally caused S/W interrupts include: * Breakpoints set within a program for debugging purposes. * Exceptions issued in Java code. ~ An OS may include up to hundreds of S/W interrupts for different purposes. Dr. Soha S. Zaghloul 16

S/W Interrupts - Exceptions Classes The set of S/W interrupts that a computer supports depends on the system s architecture. For example, Intel IA-32 architecture supports a set of three exceptions: * Faults * Traps * Aborts The class of exception specifies the behavior of the running process. Faults cause the running process to stop execution (abort). After the problem is corrected, the stopped process restarts. Traps continue executing the running process after giving a message. Examples include breakpoints and overflow (the value stored in a register exceeds its capacity). Aborts lead to a system crash. The OS may not be even able to store the state of the running process. Examples include hardware failure; or an exception handling itself causes another exception: this is called doublefault exception. Dr. Soha S. Zaghloul 17

H/W vs. S/W Interrupts H/W-generated S/W-generated ~ Generated by H/W devices ~ Generated by programs ~ Issued to inform the CPU that an event occurred (ie. H/W status changed) ~ Examples: * A keyboard issues an interrupt when the user presses a key * A printer issues an interrupt upon completion ~ Asynchronous: time-independent of running instruction ~ Issued when an error occurs or intentionally for debugging purposes ~ Examples: *Division by zero *A H/W device is malfunctioning *Breakpoint/Exception in the code *Accessing a protected memory area (reserved for the OS) *Accessing an out-of-memory address ~ Synchronous: time-dependent of the running instruction Dr. Soha S. Zaghloul 18