01计算机组成原理与体系结构

6-磁盘工作原理

2021-07-21 135 4

简介 了解磁盘结构与参数,磁盘的移臂调度算法

1. 磁盘结构与参数

    一个磁盘多个扇面, 每个扇面对应一个磁头, 磁头的运动都是同步的, 所以存储数据的时候建议将数据存储在硬盘的同一个柱面上,减少寻道时间。 多个扇面的同一磁道形成一个柱面。

upfile


    磁道:如图所示

    扇区: 如图所示


upfile


    柱面: 多个盘面上磁道号相同的多个磁道,构成一个柱面



2. 存取时间计算

    存取时间 =  寻道时间+ 等待时间(平均定位时间 + 转动延迟时间)  ----不包含读取的时间

    注意: 寻道时间是指磁头移动到磁道所需时间; 等待时间为等待读写的扇区˚所用的时间。

    ◆平均存取时间( Average Access Time),是指磁头找到指定数据的平均时间,没有包含找到扇区开始读取数据或者找到某个扇区开始写数据。

    平均存取时间是指磁头找到指定数据的平均时间,通常它是硬盘平均寻道时间和平均潜伏时间(等待时间)之和。平均存取时间最能代表硬盘找到某一数据所用的时间,数值越小越好。

    ◆平均访问时间=平均寻道时间+平均等待时间

    

    

读取磁盘数据的时间

    包含一下三部分

(1)找磁道的时间。

(2)找块(扇区)的时间,即旋转延迟时间。

(3)传输时间。


3. 移臂调度算法


先来先服务(FCFS)

    FCFS: (First Come First Served)FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are addressed in the order they arrive in the disk queue.

    Suppose the order of request is- (82,170,43,140,24,16,190)

    类似我们去银行排队办理业务,“先来后到”,谁先来先给谁提供服务,那么扫描的顺序为 82,170,43,140,24,16,190


upfile


最短寻道时间优先(SSTF)

    SSTF: In SSTF (Shortest Seek Time First), requests having shortest seek time are executed first. So, the seek time of every request is calculated in advance in the queue and then they are scheduled according to their calculated seek time. As a result, the request near the disk arm will get executed first. SSTF is certainly an improvement over FCFS as it decreases the average response time and increases the throughput of system.

    Suppose the order of request is- (82,170,43,140,24,16,190), And current position of Read/Write head is : 50

    也就是先扫描礼磁道号50最近的磁道,那就是43,然后再找离43最近的磁道,找到了24,依次类推, 每次都是从队列中找距离当前磁道最近的磁道。

    比FCFS效率高,减少了寻道时间。

    最终的扫描顺序为 43, 24, 16, 82, 140, 170, 190

upfile


扫描算法(SCAN)

    SCAN: In SCAN algorithm the disk arm moves into a particular direction and services the requests coming in its path and after reaching the end of disk, it reverses its direction and again services the request arriving in its path. So, this algorithm works as an elevator and hence also known as elevator algorithm. As a result, the requests at the midrange are serviced more and those arriving behind the disk arm will have to wait.

    也称为电梯算法,类似电梯上下的过程,谁都可以在电梯口按电梯,电梯上下的过程中,谁在某一层需要乘坐电梯,那么电梯就在那一层停。

    Suppose the requests to be addressed are-82,170,43,142,24,16,190. And the Read/Write arm is at 50, and it is also given that the disk arm should move “towards the larger value”.

    最终的扫描的顺序为 82, 142, 170, 190, 43, 24, 16

upfile



循环扫描算法( CSCAN)

    CSCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned, after reversing its direction. So, it may be possible that too many requests are waiting at the other end or there may be zero or few requests pending at the scanned area.

    These situations are avoided in CSCAN algorithm in which the disk arm instead of reversing its direction goes to the other end of the disk and starts servicing the requests from there. So, the disk arm moves in a circular fashion and this algorithm is also similar to SCAN algorithm and hence it is known as C-SCAN (Circular SCAN).

    Suppose the requests to be addressed are-82,170,43,142,24,16,190. And the Read/Write arm is at 50, and it is also given that the disk arm should move “towards the larger value”.

    只能单向扫描,也就是如果磁头目前如果在50号磁道,那么扫描的顺序为  82, 142, 170, 190, 此时磁头从磁道号为0开始再次扫描,扫描的顺序为 16, 24, 43

    那么最终的扫描顺序为  82, 142, 170, 190, 16, 24, 43

    

    upfile


点赞 4

文章评论

欢迎您:

纸上得来终觉浅,绝知此事要躬行!

112 文章 38820 浏览 3 评论

联系我

  •   QQ:    361352119
  •  Email:  lisimmy@sina.com
  • 微信: