简体   繁体   English

澄清多线程/异步/并行编程

[英]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. 写入文件时,即使同时有等待处理的请求也不会使用CPU。 A general indication of these systems is a long response time with low CPU usage, even in stress conditions. 这些系统的一般指示是即使在压力条件下,响应时间长且CPU使用率低。

How is it that a CPU is not being used when a file is being written? 如何在写入文件时不使用CPU?

Hope my question is clear. 希望我的问题很明确。

CPU正在等待硬件指示它已完成处理所请求的操作,您的处理器不会将文件写入硬盘,这是由IDE / SATA / RAID控制器处理的。

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. 基本上,当您“写入”文件时,您会将信息发送到硬盘驱动器(此位使用CPU),但是随后您需要等待信息已物理写入磁盘。 This waiting time doesn't use CPU but is significantly longer that the previous one. 此等待时间不使用CPU,但显着长于前一个。 The same when you load, you spend 99% of the time waiting for the harddrive to fetch the information physically. 加载时相同,您花费99%的时间等待硬盘驱动器以物理方式获取信息。

Because the CPU is waiting for a response from the disk. 因为CPU正在等待磁盘的响应。 The disk is an independent unit, which is communicating with the CPU through a serial bus (or parallel bus for older disks). 磁盘是一个独立的单元,它通过串行总线(或旧磁盘的并行总线)与CPU通信。 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. 将一个数据包发送到要写入的磁盘,然后CPU只能等到磁盘完成它的工作,并返回所请求操作的状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM