Interrupts and signals

Slides:



Advertisements
Similar presentations
Computer Organization and Architecture
Advertisements

Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
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.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Chapter 5 Input/Output I/O Hardware I/O Software Software Layers Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
System Calls 1.
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
Introduction to Operating Systems Chapter 1. cs431 -cotter2 Lecture Objectives Understand the relationship between computing hardware, operating system,
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
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.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
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.
1.4 Hardware Review. CPU  Fetch-decode-execute cycle 1. Fetch 2. Bump PC 3. Decode 4. Determine operand addr (if necessary) 5. Fetch operand from memory.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
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.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
CSCE451/851 Introduction to Operating Systems
Introduction to Operating Systems Concepts
System Calls, Interrupts and Exceptions
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Computer System Overview
Interrupts and exceptions
CS501 Advanced Computer Architecture
Microprocessor Systems Design I
Basic Processor Structure/design
CS 6560: Operating Systems Design
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
William Stallings Computer Organization and Architecture 8th Edition
Anton Burtsev February, 2017
Protection of System Resources
Day 08 Processes.
Day 09 Processes.
CS 3305 System Calls Lecture 7.
Chapter 3 Top Level View of Computer Function and Interconnection
Structure of Processes
Module 2.2 COP4600 – Operating Systems Richard Newman
Computer System Overview
Computer Organization and ASSEMBLY LANGUAGE
More examples How many processes does this piece of code create?
Module 2.1 COP4600 – Operating Systems Richard Newman
Processor Fundamentals
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
COMPUTER PERIPHERALS AND INTERFACES
Architectural Support for OS
Computer Organization
Operating Systems Lecture 3.
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Computer System Overview
Lecture 6: Multiprogramming and Context Switching
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
CS510 Operating System Foundations
Computer System Overview
Architectural Support for OS
CPU Structure and Function
Chapter 11 Processor Structure and function
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Presentation transcript:

Interrupts and signals Module 2.3 COP4600 – Operating Systems Richard Newman

Asynchronous events Exceptions – something the current process does Software – explicitly raise exception when problem occurs Hardware – trap when problem occurs (overflow, DBZ, etc.) Software Signal – something another process does Sent by one process to another process Restrictions on who can send a process a signal May be caught by receiving process – signal handler Hardware Interrupt – something some hardware does Device raises signal line Line checked every instruction Causes reaction by hardware – jump to interrupt vector May be ignored – protection state/interrupt mask

Interrupts and signals Hardware Interrupt - examples Clock “tick” I/O device done Peripheral needs service Software Signal - examples Hardware exception – system sends process a signal Wakeup signal from watchdog timer Alert that file contents have changed Kill signal – terminate process (can’t be caught)

Figure 2-39. Interrupt processing hardware on a 32-bit Intel PC. Interrupt hardware What if there are more than 8 devices that need to be able to signal the CPU? Chain IRQ controller using one interrupt line for slave. Meaning of interrupt numbers found in include/ibm/interrupt.h Figure 2-39. Interrupt processing hardware on a 32-bit Intel PC. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Interrupts Revisited 5 1 7 4. IC gives IRQ number Figure 5-5. How an interrupt happens. The connections between the devices and the interrupt controller actually use interrupt lines on the bus rather than dedicated wires. Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Interrupt handling from running process perspective Four processes involved: Process P1 that made disk access request (gets blocked) -------------------------------------- Process that is running when I/O done (INT occurs) Interrupt handler, but it is not considered a process Device driver System service (FS) Figure 1-11. (b) Interrupt processing involves taking the interrupt, running the interrupt handler, and returning to the user program. Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Servicing Interrupts IRQ causes trap to kernel code (same for all IRQs) Looks up interrupt vector according it interrupt number Also need to change protection state – kernel mode Run interrupt service routine (ISR) Not code in current process – system code Must use CPU and its registers May also need its own stack space Save state of currently running process: Context switch Special Registers – PC, CIR, PSW, etc. General purpose registers – current data being operated on Memory and resource information – stack pointer, etc.

Interrupt: process perspective RAM Interrupt Handler Code Current Process Code Current Process is running Interrupt occurs Trap to kernel – fixed entry point Find ISR address in interrupt vector table Context switch code loads ISR Interrupt handler (ISR) executes Return – CS code loads process Process resumes execution Primary IH Service Code ASM context switch

MINIX Memory Table of addresses (vectors) of kernel code to handle interrupts, indexed by interrupt number Figure 2-31. Memory layout after MINIX 3 has been loaded from the disk into memory. The kernel, servers, and drivers are independently compiled and linked programs, listed on the left. Sizes are approximate and not to scale. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

pointing to handler code Stack needed By service routine In table of addresses indexed by interrupt # pointing to handler code Interrupt service Figure 2-5 Skeleton of what the lowest level of the operating system does when an interrupt occurs. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Restart Figure 2-41. Restart is the common point reached after system startup, interrupts, or system calls. The most deserving process (which may be and often is a different process from the last one interrupted) runs next. Not shown in this diagram are interrupts that occur while the kernel itself is running. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Layers of the I/O System Figure 3-8. Layers of the I/O system and the main functions of each layer. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Device Drivers in MINIX 3 Figure 3-16. Two ways of structuring user-system communication. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Interrupts Revisited Figure 5-5. How an interrupt happens. The connections between the devices and the interrupt controller actually use interrupt lines on the bus rather than dedicated wires. Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Multiple interrupts What if interrupt occurs while servicing an interrupt? Usually interrupt service routines block interrupts Interrupt mask – register Protection state – may automatically mask interrupts Setting interrupt mask is protected instruction Restore interrupts Must remember old interrupt mask to restore it Check for additional interrupts when service routine done

Fetch-decode-execute cycle revisited Copy instruction from RAM into IR Increment PC Decode Interpret opcode Execute Carry out instruction – invoke ALU or move data, etc. Check status register Handle exceptions Check interrupt line If interrupts enabled Service interrupt(s)

Precise Interrupt Four properties of a precise interrupt: The PC saved in a known place. All instructions before that pointed to by PC have fully executed. No instruction beyond that pointed to by PC has been executed. Execution state of instruction pointed to by PC is known. Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Figure 5-6. (a) A precise interrupt. (b) An imprecise interrupt. Precise vs. Imprecise Figure 5-6. (a) A precise interrupt. (b) An imprecise interrupt. Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Interrupts vs. System Calls Figure 2-40. How a hardware interrupt is processed. How a system call is made. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Figure 1-17. The steps in making a read system call System Calls Codes for system calls found in include/minix/callnr.h Regular procedure call stuff Trap (INT) and context switch Figure 1-17. The steps in making a read system call Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Figure 4-40. Three phases of dealing with signals. Signal handling More on this later…. Figure 4-40. Three phases of dealing with signals. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Figure 4-42. Signals defined by POSIX and MINIX 3. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Figure 4-42. Signals defined by POSIX and MINIX 3. More Signals Figure 4-42. Signals defined by POSIX and MINIX 3. Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Summary Asynchronous events Needed for multiprogramming and I/O Exceptions, signals, interrupts Needed for multiprogramming and I/O Interrupt handling Context switch Interrupt vectors Fetch-Decode-Execute revised Comparison to System Calls Signal handling