Toll-free:

Do you have
any questions?

http://marvelous-essay.net/

How Operating Systems Handle Interrupts and I/O

Buy custom How Operating Systems Handle Interrupts and I/O essay

An interrupt is an event that requires the CPU to stop normal program execution and perform some service to this event. Interrupts can be internal or external. An external interrupt is generated when external circuitry asserts an internal signal to the CPU (Han-Way 200). On the other hand, an internal interrupt can be generated by the hardware circuitry in the CPU or as a result of software errors. The operating system plays an important role handling interrupts and I/O’s.  

Input and output devices normally use interrupts to communicate information about I/O operations. The interrupts must be handled by the operating system because they cause a transfer to kernel or supervisor mode (Patterson and Hennessy, 588). The functions of the operating system arises from the basis that multiple programs using the processor share the I/O system. Patterson and Hennessy (588) further noted that the operating system must ensure that user’s program accesses only parts of the input and output device to which the user has rights. For example, the operating system must not allow a program to modify a file on a device if the owner of the file has not given permission to have access to the program.

One of the most basic tasks of an operating system is to take care of I/O functions which let other programs to communicate with the computer hardware. The I/O functions take requests from the software the user runs and translate them into low-level requests that the hardware can understand and carry. An operating system serves as an interface between application software and hardware. In this context, an operating system must handle input from keyboard, mouse and other input devices and at the same time handle output to the monitor and printer.  

The current processors offer methods that allow external I/O devices to interrupt the operating system. Comer says that processors have related exception method that is utilized to inform the application when an error or fault takes place (40). In the perspective of an operating system, interrupts are significant because they allow the central processing unit to perform computation at the same time I/O continues. I/O devices connected to a bus can interrupt the processor when the device requires a service. Comer says that for this to occur, the device places a signal on one of the bus control lines (40). During normal execution of the fetch-execute cycle, hardware in the processor monitors the control line and initiates interrupt processing when the control line has been informed (Comer 40).

Interrupt-driven I/O, which is used by almost all operating systems for at least some devices, employs I/O interrupts to indicate to the processor that an I/O device needs attention. Patterson and Hennessy (591) indicated that when an I/O device wants to notify the processor that it has completed some operation or needs attention, it causes the processor to be interrupted. To communicate information to the processor such as the identity of the device raising the interrupt, an operating system can use either vectored interrupts or an exception cause register. When the processor recognizes the interrupt, the device can send either the vector address or a status field to place in the cause register (Patterson and Hennessy, 588). As a result, when the operating system gets control, it knows the identity of the device that causes the interrupt and can quickly interrogate the device. An interrupt mechanism eliminates the need for the processor to poll the device and instead allows the processor to focus on executing programs.  

While it manipulates global data structures and I/O queues, an operating system must prevent interrupts from occurring. Comer says that hardware supplies mechanisms to control interrupts (40). One of the registers in the co-processor is an interrupt mask that the operating system uses to specify which devices are permitted to interrupt. Each bit in the mask corresponds to an interrupt source in the system. A source can consist of devices on the system bus, internal timers, or can rise from the execution of special processor encode (Comer 40). The initial value of all bits is zero, which implies the corresponding source cannot interrupt. When it starts an I/O device, the operating system sets the corresponding mask bit to one, which allows the device to interrupt.

To handle precedence’s of the I/O devices, most interrupt mechanisms have several levels of priority; Unix operating system utilizes four to six levels. These priorities indicate the order in which the operating system should process interrupts. It is important to note that both internally generated exceptions and external I/O interrupts have priorities. Essentially, I/O interrupts have lower priority than internal exceptions (Patterson and Hennessy 591).

Operating systems embrace interrupt system because they are interrupt-driven. Operating systems basically wait for interrupts to drive them to execute their tasks. The operating system must be prepared to handle interrupts as they occur, and most hardware interrupts occur asynchronously or at any time (El-Haik and Shaout 60). There are two main types of interrupts, hardware and software. El-Haik and Shaout says that with hardware interrupts, the operating system is not responsible for the executing code to handle the interrupt. Instead the CPU usually handles the interrupt without the assistance of any software. However, the operating system handles two things of the interrupt. The first includes loading the program counter with the memory address of the Interrupt Service Routine (ISR). The second is that when the ISR completes, it loads the program counter with the next instruction of the task it interrupted (El-Haik and Shaout 60). 

Software interrupt instructions are specifically used to call the operating system. These instructions are shorter than subroutine calls, and no calling program is needed to know the operating systems address in memory (Rafiquzzaman 80). Unlike hardware interrupts, software interrupts instructions allow the user to switch from user to supervisor mode. Rafiquzzaman (80) established that for some processors, a software interrupt is the only way to call the operating system, because a subroutine call to an address in the operating system is not allowed. Research shows that switching interrupts off allows the operating system to handle higher precedence interrupts without being disturbed by other probably lower precedence interrupts. It is also important to note that there are interrupts that are caused by errors, interrupts that cause the operating system to execute certain tasks and those that do not have any established service routines. The operating system must handle these interrupts efficiently and timely to facilitate multitasking.    

When the operating system is handling interrupts, it first sets a control bit that disables further interrupts. Comer says that this step ensures that while it is processing an interrupt from one device, the operating system will not be interrupted by another service (40). The second step involves recording the address of the instruction that is about to execute. This step provides a way for an operating system to return to normal execution once the interrupt has been processed. The third step involves restoring to the reserved location which ensures that the operating system gains control whenever an interrupt occurs (Comer 40). Before an interrupt occurs, the operating system must store interrupt processing code at the reserved location. According to Comer (40) this ensures that the complier and loader start the operating system at the same location and guarantees that code can be stored in the reserved location without affecting other values in the operating system. 

Buy custom How Operating Systems Handle Interrupts and I/O essay

Related essays

 

Get 15% off your first custom essay order.

Order now

PRICES
from $12.99/PAGE
X

Tell a friend