Why is the CPU not needed to service I/O requests?

I am learning about operating systems but there is a small concept I cannot grasp. Say a process 1 is running on the CPU and then it issues an I/O request to read from a disk. For efficiency, the CPU begins executing process 2 as this request is handled. That all makes sense but doesn't the I/O need to use the CPU?

enter image description here

My Question: Why isn't the CPU needed to service process 1's request?

10298 次浏览

It would help to understand the role of 3 important aspects of I/O in computer architecture: Interrupts, DMA, and Hardware Controllers.

When the CPU issues an I/O request to the hard disk, the hard disk has its own specialized chip called a device (or hardware) controller designed solely for processing commands from the CPU, such as reading from the disk. Originally these were simple chips that performed specific operations for the CPU, but modern hardware controllers are basically their own microprocessors with firmware and everything, so they are capable of very complex operations without the main CPU's help. While the hard drive's controller is busy performing the request, the main CPU is free to do whatever it wishes, such as execute process 2 in your example. The controller is able to read and write directly to and from system RAM using what is called a Direct Memory Access (DMA) controller, a special unit that transfers data from the hardware controller to main RAM without the CPU needing to do anything.

When the hard drive is done with the request and the relevant data has been loaded into RAM through DMA, it issues an interrupt request which informs the CPU that the data has been loaded into RAM. At this point the CPU can transfer control back to process 1. Thus, the CPU does not need to micromanage all tasks involved with I/O. At one time this used to be the case, but these tricks (interrupts, DMA, special controllers) were invented in order to improve CPU performance and make things more efficient.

Cpu is used to initiate every io request and then accept it when ready ...it is not the case that cpu is not involved in io operations.

E.g copy 2gb file from c drive to d drive and open task manager ..in performance tab u will see both disk utilization as well as cpu usage.

Proving my.point.

Ahsan