ckv
ckv

Reputation: 10838

Clarification on multithreaded/asynchronous/parallel programming

I have been reading many articles in the net on multithreaded/asynchronous/parallel programming and often I have come across a similar statement as below.

While a file is being written, the CPU will not be used even if in the meantime there are requests waiting to be processed. A general indication of these systems is a long response time with low CPU usage, even in stress conditions.

How is it that a CPU is not being used when a file is being written?

Hope my question is clear.

Upvotes: 2

Views: 108

Answers (3)

Guffa
Guffa

Reputation: 700860

Because the CPU is waiting for a response from the disk. The disk is an independent unit, which is communicating with the CPU through a serial bus (or parallel bus for older disks). The technical difference between an internal and an external drive is actually mostly whether it's inside or outside the computer box.

A packet of data is sent to the disk to be written, and then the CPU can only wait until the disk has done it's job, and returns the status of the operation requested.

Upvotes: 1

mb14
mb14

Reputation: 22636

Basically when you 'write' on a file, you send information to the hard-drive (this bit use CPU) but then you need to wait that the information have been physically written to the disk. This waiting time doesn't use CPU but is significantly longer that the previous one. The same when you load, you spend 99% of the time waiting for the harddrive to fetch the information physically.

Upvotes: 2

Sean Airey
Sean Airey

Reputation: 6372

The CPU is waiting for the hardware to indicate that it is done processing the requested operation, your processor doesn't write files to the hard disk, that's handled by your IDE/SATA/RAID controller.

Upvotes: 4

Related Questions