Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 337
Pat Murray Avatar asked Nov 28 '12 02:11

Pat Murray


People also ask

Why is CPU idle during Io?

iowait is time that the processor/processors are waiting (i.e. is in an idle state and does nothing), during which there in fact was outstanding disk I/O requests. This usually means that the block devices (i.e. physical disks, not memory) is too slow, or simply saturated.

What is the difference between CPU and I O bound operations?

A CPU-bound process is one that spends most of its time executing instructions on the processor. A process that is I/O-bound spends most of its time waiting for input and output operations to complete. It is critical for a scheduler to discern between the two in order to maintain a balanced system.

What is IO CPU?

The input/output processor or I/O processor is a processor separate from the CPU designed to handle only input/output processes for a device or the computer. The I/O processor is capable of performing actions without interruption or intervention from the CPU.

What is CPU I O wait?

For a given CPU, the I/O wait time is the time during which that CPU was idle (i.e. didn't execute any tasks) and there was at least one outstanding disk I/O operation requested by a task scheduled on that CPU (at the time it generated that I/O request).


1 Answers

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.

like image 126
Dougvj Avatar answered Oct 15 '22 15:10

Dougvj