The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

Computer System Organization Computer-system operation – One or more CPUs, device controllers connect through common bus providing access to shared memory.
CSCI 4717/5717 Computer Architecture
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
1 Computer System Overview OS-1 Course AA
Chapter 7 Interupts DMA Channels Context Switching.
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.
Computer Organization and Architecture
1 When to Switch Processes 3 triggers –System call, Interrupt and Trap System call –when a user program invokes a system call. e.g., a system call that.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
Exceptions, Interrupts & Traps
INTERRUPTS PROGRAMMING
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
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.
Interrupts Signal that causes the CPU to alter its normal flow on instruction execution ◦ frees CPU from waiting for events ◦ provides control for external.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Computer System Overview Chapter 1. Operating System Exploits the hardware resources of one or more processors Provides a set of services to system users.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
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.
Operating Systems Process Management.
Interrupt.
Computer Architecture Lecture 2 System Buses. Program Concept Hardwired systems are inflexible General purpose hardware can do different tasks, given.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
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.
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.
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.
Chapter 6: Computer Components Dr Mohamed Menacer Taibah University
Lecture 1: Review of Computer Organization
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Structure and Role of a Processor
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
Processes 2 Introduction to Operating Systems: Module 4.
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.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
9691 Computing Paper 3 Section 3.1 The functions of Operating Systems.
Processes and threads.
Operating Systems CMPSC 473
Microprocessor Systems Design I
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Advanced OS Concepts (For OCR)
Day 08 Processes.
Day 09 Processes.
Computer System Overview
Processor Fundamentals
BIC 10503: COMPUTER ARCHITECTURE
Processes Hank Levy 1.
Components of a CPU AS Computing - F451.
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
Processes Hank Levy 1.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

The Functions of Operating Systems Interrupts

Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of interrupted jobs may later be resumed. Identify typical sources of interrupts Describe algorithms and data structures associated with interrupts.

The simplest way of obeying instructions Sometimes the normal order of operation is changed by an interrupt. See next slide.

Interrupts Signals sent to the processor by devices / programs indicating that they require the attention of the processor. Due to errors or because of speed mismatch implications. Due to errors or because of speed mismatch implications. i.e. In order to save time, perform other tasks and wait to be interrupted by the I/O device when it is ready to continue.

Types Of Interrupts

I/O or Hardware interrupt Generated by hardware (I/O devices) to signal a service request (allows resolution of speed mismatch implications) or an error has occurred. E.g. E.g. Printer has emptied the buffer and wants it refilled. Printer is out of paper or is not connected. Close down safely in the event of a power failure from: A Uninterruptible Power Supply (UPS) which took over when the main electricity was lost but now its rechargeable power supply is running low. A Uninterruptible Power Supply (UPS) which took over when the main electricity was lost but now its rechargeable power supply is running low. The device which measures how much power is still left in a laptop battery informs the processor it is running low. The device which measures how much power is still left in a laptop battery informs the processor it is running low.

Timer / Clock Interrupt Generated at fixed intervals. Allows for display refresh and to control access to processor in multi-access or multi- programming system.

Program interrupt Generated due to an error in a program: Violation of memory use (trying to use part of the memory reserved by the OS for another use). Violation of memory use (trying to use part of the memory reserved by the OS for another use). An attempt to execute an invalid instruction (e.g. division by zero). An attempt to execute an invalid instruction (e.g. division by zero).

Terms Job / Process / Task / Program are all equivalent terms. Cycle is an instruction in a job / process / task / program.

Managing interrupts After the execution of an instruction (current cycle), the processor must see if an interrupt has occurred and service it. i.e. Obey a new set of instructions.

Type/Source of interrupt is checked and priority (different types have different priorities) of interrupt compared with current job. How this priority is decided is called scheduling and is dealt with in the next presentation. schedulingnext presentationschedulingnext presentation

If higher:

Masking / Disable equal or lower priority interrupts Mask out, refuse or disable all interrupts of an equal or lower priority than the current interrupt being serviced. Effectively meaning that any further interrupts will (in the execution of the current one) have to be of a higher priority if it is to interrupt the current interrupt. Effectively meaning that any further interrupts will (in the execution of the current one) have to be of a higher priority if it is to interrupt the current interrupt. This is done by using a Programmable Interrupt Controller (PIC) which is separate from the processor. All interrupts have to state their Interrupt Priority Level (IPL) and the PIC does not pass on any new interrupts to the processor unless they have a higher IPL (lower priority interrupts are therefore simply ignored). This allows the current interrupt to be executed without having to waste time considering equal or lower priority interrupts. How this priority is decided is called scheduling and is dealt with in the next presentation. schedulingnext presentationschedulingnext presentation

How can the interrupted program be resumed from where it left off when the interrupt has been serviced? The state of the current job is saved by saving the contents of all the registers (small, permanent storage locations within the CPU used for a particular purpose) in the processor so that the processor can use them to service the interrupt but can load their contents back in to resume the job being interrupted once the interrupt has been serviced. The first register to be saved is one called the Program Counter which holds the address of the next instruction. The first register to be saved is one called the Program Counter which holds the address of the next instruction. Then the other registers are saved. Then the other registers are saved. For more information see the. For more information see the Von Neumann Architecture Presentation, later in this course.Von Neumann Architecture Presentation

Scheduling processes and the Process Control Block (PCB). Each job is allocated a block of memory called a process control block. This will hold the following information: Process Identity Number. Current state of the job when the job was last left. The contents of each register when the job was last left on a stack. What priority the process has. Estimated time for the job to be finished. It's current status, whether it is waiting for I/O, whether it's waiting to use the CPU. Pointers pointing to areas in memory reserved for this process and resources that could be used. When a process is stopped, the above details are loaded into the Process Control Block, ready for next time the process uses CPU time. When that time comes, the contents of the PCB are moved into the CPU and the process repeats itself!

Interrupt Service Routine (ISR) Place the current job in a “queue of interrupts” (position depends on its type/source and priority). An appropriate interrupt service routine (ISR), depending on the type and actual task of the interrupt, is loaded and run. Device driver in case of devices. Device driver in case of devices. Exception / signal / trap handler in case of software interrupts. Exception / signal / trap handler in case of software interrupts. OK, I have been interrupted. Now the CPU asks the hardware: 'What do you want me to do'? In other words: 'Which interrupt service routine should I run?' Interrupt is serviced by the processor. How this priority is decided is called scheduling and is dealt with in the next presentation. schedulingnext presentationschedulingnext presentation

Enable ALL interrupts When the interrupt is complete the processor will start considering all interrupts of a lower priority. i.e. enable or restore or unmask all equal and lower priority interrupts. i.e. enable or restore or unmask all equal and lower priority interrupts. Restore the contents of the registers for the next process in the queue of interrupts. Resume this process.

If an ISR is being run (lower priority interrupts are being masked) then it is ignored until the current interrupt is finished then its priority is compared to jobs in the queue, if lower than the next waiting job then or otherwise: Allocate the job a position in a job queue according to its priorities. If equal or lower: How this priority is decided is called scheduling and is dealt with in the next presentation. schedulingnext presentationschedulingnext presentation

Summary: 1.Disable interrupts of a lower priority. 2.Save the contents of the program counter on a stack in the Process Control Block. 3.Save all other registers and any other information needed to resume the current process. 4.Load and run the appropriate Interrupt Service routine (ISR). 5.If a higher priority interrupt is received then go to step 1. 6.When ISR is complete enable all interrupts of a lower priority and complete the task next in the queue of interrupts. When the next task has been chosen: 7.Restore all other registers. 8.Restore the Program Counter. 9.Continue execution of the interrupted original process.

Also note: Some websites like the one above state that only the PC is saved before running the ISR and that it is part of the ISR’s job to save any of the other registers it will use; so that the previous job can resume from where it left off. This is so other registers are not saved unnecessarily as only the PC will definitely be changed (the address of the next instruction). If this is so, steps 3 & 4 and 6 & 7 (as the ISR would have to restore the registers it saved) on the previous slide, should be swapped round. This appears to be why mark schemes differ slightly from other sources in regards to the exact sequence, and therefore I predict some flexibility here. ‎ For more research:

Plenary State and explain all the different types of interrupt that may occur.

Types of Interrupt I/O interrupt Generated by an I/O device to signal that a job is complete or an error has occurred. Generated by an I/O device to signal that a job is complete or an error has occurred.E.g. Printer is out of paper or is not connected. Printer is out of paper or is not connected. Timer interrupt Generated at fixed intervals. Generated at fixed intervals. Allows for display refresh and to control access to processor in multi-access or multi-programming system. Allows for display refresh and to control access to processor in multi-access or multi-programming system.

Plenary How is an interrupt handled by a processor which is working on another task?

Summary: 1.Disable interrupts of a lower priority. 2.Save the contents of the program counter and all other registers on a stack in the Process Control Block. 3.Save any other information needed to resume the current process. 4.Load and run the appropriate Interrupt Service routine (ISR). 5.If a higher priority interrupt is received then go to step 1. 6.When ISR is complete enable all interrupts of a lower priority and complete the task next in the queue of interrupts. If continuing a previous task: 7.Restore all other registers. 8.Restore the Program Counter. 9.Continue execution of the interrupted original process.