interrupt handling in os.doc

Upload: deepak-dinesh

Post on 14-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Interrupt Handling in OS.doc

    1/2

    Interrupt Handling in OS

    All of the process state changes are interrupt-driven. An interrupt is a signal generated byan event that alters the sequence in which a processor executes instructions. It is

    generated by the hardware of the computer systems. When an interrupt occurs, the OS

    saves the state of the interrupted process and passes control to the appropriate routine.

    An interrupt may be initiated by the currently running process or it may be caused by

    some event which may or may not be related to the currently running process.

    Types of interrupt

    The following different types of interrupts may occur:

    1. interrupts generated by a running process : The process might need to

    perform I/O, obtain more storage or communicate with the operator.

    2. i/o interrupts : these are initiated by the I/O hardware and signal to the CPU

    that the status of a channel or device has changed. An I/O interrupt will occurin the following situations - when I/O operations is complete, when an error

    occurs or when a device is made ready.

    3. External Interrupts: These could be caused by the interrupt timer on expiryof a time slice, or the operator pressing an interrupt key, or the receipt of

    signal from another processor on a multiprocessor system.

    4. Restart Interrupts: These occur when the operator presses the restart button.

    5. Program check for interrupts: These are caused by various types of errorssuch as division by zero.

    6. Machine check interrupts: These are caused by malfunctioning hardware.

    How the interrupt Mechanism works

    These a special register in the CPU called the interrupt register. At the beginning of each

    fetch-execute cycle, the interrupt register is checked. Each bit of the register represents a

    different type of interrupt, and if a bit is set, the state of the current process is saeed andthe OS routes control to the appropriate interrupt handler.

    Since more than one device may request an interrupt simultaneously, each device isassigned a priority. Slow-speed devices such as terminals and printers are given a high

    priority, since they are more liable to get behind with what they are doing, and so should

    be allowed to start as soon as possible so that they do not eventually hold up the

    processing.

  • 7/27/2019 Interrupt Handling in OS.doc

    2/2

    In some cases if an interrupt occurs during data transfer, some data could be lost, and so

    the OS will disable other interrupts until it completes its task.

    In a large multi-procesor system there is a constant stream of interrupts directed at the

    processor and it must respond as quickly as possible to these in order to provide an

    acceptable response time. Once an interrupted is received, the OS disables interruptswhile it deals with the correct interrupt. Since this could mean that interrupts are disabled

    for a larger proportion of the time, the nucleus on larger systems simply determines the

    cause of the interrupt and then passes the problem over to the specific interrupt handler,leaving itself free to deal with the next interrupt.

    A special indicates register called the PSW (Program Status Word) indicates the types of

    interrupts currently enabled and those currently disabled. The CPU allows enabledinterrupts to occur; disabled interrupts remain pending, or in some cases are ignored.

    In samller systems, the OS handles all interrupts itself, which means the interrupts are

    disabled for a larger proportions of time.

    Example: Program is currently a running process. It needs to retrieve some datafrom disk, so an interrupt is generated. The interrupt handler change the status of :A: to

    blocked., mmake a request for the disk drive, for data and invokes a program called the

    dispatcher