Open In App

Difference between Programmed and Interrupt Initiated I/O

Last Updated : 28 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Between CPU and I/O devices can be processed by several modes in the computer systems. There are two main ways that are used in I/O operations, and they include programmed I/O and interrupt initiated I/O. The decision on these modes has affected the performance of the system. The reader will find in this article a comparison of the operation of these modes, their advantages and disadvantages, as well as the impact they have on the efficiency of the overall system. 

What is Programmed I/O? 

In this mode the data transfer is initiated by the instructions written in a computer program. An input instruction is required to store the data from the device to the CPU and a store instruction is required to transfer the data from the CPU to the device. Data transfer through this mode requires constant monitoring of the peripheral device by the CPU and also monitor the possibility of new transfer once the transfer has been initiated. Thus CPU stays in a loop until the I/O device indicates that it is ready for data transfer. Thus programmed I/O is a time consuming process that keeps the processor busy needlessly and leads to wastage of the CPU cycles. This can be overcome by the use of an interrupt facility. This forms the basis for the Interrupt Initiated I/O. 

Advantages of Programmed I/O

  • Provides simple and easy interfaces to programs.
  • Direct access to interact with the CPU without involving any peripheral devices in the process.

Disadvantages of Programmed I/O

  • Synchronization is not efficient in terms of the CPU time as it will need to loop waiting for the device to be ready.
  • The CPU is idle and cannot handle any other task at the time it waits for the I/O device to complete processing.

What is Interrupt Initiated I/O?

This mode uses an interrupt facility and special commands to inform the interface to issue the interrupt command when data becomes available and interface is ready for the data transfer. In the meantime CPU keeps on executing other tasks and need not check for the flag. When the flag is set, the interface is informed and an interrupt is initiated. This interrupt causes the CPU to deviate from what it is doing to respond to the I/O transfer. The CPU responds to the signal by storing the return address from the program counter (PC) into the memory stack and then branches to service that processes the I/O request. After the transfer is complete, CPU returns to the previous task it was executing. The branch address of the service can be chosen in two ways known as vectored and non-vectored interrupt. In vectored interrupt, the source that interrupts, supplies the branch information to the CPU while in case of non-vectored interrupt the branch address is assigned to a fixed location in memory. 

Interrupt-initiated I/O, also referred to as hard-initiated I/O, is where input and output operations are done when an interrupt signal is detected by the CPU. 

Interrupt-initiated I/O is a more efficient one, as the I/O device sends a signal to the CPU that it is ready for the data transfer. The CPU performs other tasks until it receives an interrupt request. 

 Advantages of Interrupt-Initiated I/O

  • Reduced overhead on the CPU as the same CPU waits for an interrupt while doing other tasks at the same instance.
  • There is also no need for monitoring the status of a specific device.
  • Reduces CPU time wastage, hence enhancing the performance of the system.

Disadvantages of Interrupt-Initiated I/O

  • Difficult to implement and program in contrast to sequential file processing or compared to it when it is implemented in low-level languages.
  • Needs interrupt handling routines, which can be time-consuming.

Difference Between Programmed and Interrupt Initiated I/O

Programmed I/O Interrupt Initiated I/O
Data transfer is initiated by the means of instructions stored in the computer program. Whenever there is a request for I/O transfer the instructions are executed from the program. The I/O transfer is initiated by the interrupt command issued to the CPU.
The CPU stays in the loop to know if the device is ready for transfer and has to continuously monitor the peripheral device. There is no need for the CPU to stay in the loop as the interrupt command interrupts the CPU when the device is ready for data transfer.
This leads to the wastage of CPU cycles as CPU remains busy needlessly and thus the efficiency of system gets reduced. The CPU cycles are not wasted as CPU continues with other work during this time and hence this method is more efficient.
CPU cannot do any work until the transfer is complete as it has to stay in the loop to continuously monitor the peripheral device. CPU can do any other work until it is interrupted by the command indicating the readiness of device for data transfer
Its module is treated as a slow module. Its module is faster than programmed I/O module.
It is quite easy to program and understand. It can be tricky and complicated to understand if one uses low level language.
The performance of the system is severely degraded. The performance of the system is enhanced to some extent.

Conclusion 

In Conclusion, programmed I/O is simple but results in wastage of the CPU, while on the other hand, interrupt initiated I/O enables the CPU to do other tasks besides waiting to be served, hence resulting in the efficiency of a system. Hence there is an opportunity to select an apt mode that fits the system’s needs depending on the level of difficulty and the speed it requires to operate. 



Next Article

Similar Reads