Вы находитесь на странице: 1из 2

Interrupt Handling in OS All of the process state changes are interrupt-driven.

An interrupt is a signal generated by an 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. 2. interrupts generated by a running process : The process might need to perform I/O, obtain more storage or communicate with the operator. 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 occur in the following situations - when I/O operations is complete, when an error occurs or when a device is made ready. External Interrupts: These could be caused by the interrupt timer on expiry of a time slice, or the operator pressing an interrupt key, or the receipt of signal from another processor on a multiprocessor system. Restart Interrupts: These occur when the operator presses the restart button. Program check for interrupts: These are caused by various types of errors such as division by zero. Machine check interrupts: These are caused by malfunctioning hardware.


4. 5. 6.

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 and the OS routes control to the appropriate interrupt handler. Since more than one device may request an interrupt simultaneously, each device is assigned 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.

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 interrupts while 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 enabled interrupts 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 data from 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