磁盘调度算法sstf算法_辅助存储和磁盘调度算法

磁盘调度算法sstf算法

辅助存储和磁盘调度算法 (Secondary Storage and Disk Scheduling Algorithms)

Secondary storage devices are those devices whose memory is non volatile, meaning, the stored data will be intact even if the system is turned off. Here are a few things worth noting about secondary storage.

辅助存储设备是那些内存是非易失性的设备,这意味着即使关闭系统电源,存储的数据也将保持完整。 以下是有关辅助存储的一些注意事项。

  • Secondary storage is also called auxiliary storage.

    辅助存储也称为辅助存储。
  • Secondary storage is less expensive when compared to primary memory like RAMs.

    与主存储器(如RAM)相比,二级存储的价格便宜。
  • The speed of the secondary storage is also lesser than that of primary storage.

    辅助存储的速度也小于主存储的速度。
  • Hence, the data which is less frequently accessed is kept in the secondary storage.

    因此,较少访问的数据被保存在辅助存储器中。
  • A few examples are magnetic disks, magnetic tapes, removable thumb drives etc.

    一些示例是磁盘,磁带,可移动拇指驱动器等。

磁盘结构 (Magnetic Disk Structure)

In modern computers, most of the secondary storage is in the form of magnetic disks. Hence, knowing the structure of a magnetic disk is necessary to understand how the data in the disk is accessed by the computer.

在现代计算机中,大多数辅助存储都是磁盘形式的。 因此,必须了解磁盘的结构才能理解计算机如何访问磁盘中的数据。

磁盘调度算法sstf算法_辅助存储和磁盘调度算法

Structure of a magnetic disk

磁盘的结构



A magnetic disk contains several platters. Each platter is divided into circular shaped tracks. The length of the tracks near the centre is less than the length of the tracks farther from the centre. Each track is further divided into sectors, as shown in the figure.

磁盘包含多个磁盘 。 每个盘子分成圆形的轨道 。 靠近中心的轨道的长度小于远离中心的轨道的长度。 如图所示,每个磁道进一步划分为多个扇区

Tracks of the same distance from centre form a cylinder. A read-write head is used to read data from a sector of the magnetic disk.

距中心相同距离的轨道形成一个圆柱体。 读写头用于从磁盘的扇区读取数据。

The speed of the disk is measured as two parts:

磁盘的速度分为两个部分:

  • Transfer rate: This is the rate at which the data moves from disk to the computer.传输速率:这是数据从磁盘移动到计算机的速率。
  • Random access time: It is the sum of the seek time and rotational latency.随机访问时间:它是寻道时间和旋转等待时间的总和。

Seek time is the time taken by the arm to move to the required track. Rotational latency is defined as the time taken by the arm to reach the required sector in the track.

搜索时间是手臂移动到所需轨道所花费的时间。 旋转等待时间定义为手臂到达轨道中所需扇区所花费的时间。

Even though the disk is arranged as sectors and tracks physically, the data is logically arranged and addressed as an array of blocks of fixed size. The size of a block can be 512 or 1024 bytes. Each logical block is mapped with a sector on the disk, sequentially. In this way, each sector in the disk will have a logical address.

即使磁盘按扇区排列并在物理上进行跟踪,但数据在逻辑上按固定大小的块阵列排列和寻址。 块的大小可以是5121024字节。 每个逻辑块依次与磁盘上的一个扇区映射。 这样,磁盘中的每个扇区都会有一个逻辑地址。

磁盘调度算法 (Disk Scheduling Algorithms)

On a typical multiprogramming system, there will usually be multiple disk access requests at any point of time. So those requests must be scheduled to achieve good efficiency. Disk scheduling is similar to process scheduling. Some of the disk scheduling algorithms are described below.

在典型的多程序系统上,通常在任何时间点都会有多个磁盘访问请求。 因此,必须安排这些请求以实现良好的效率。 磁盘调度类似于进程调度。 下面描述了一些磁盘调度算法。

先到先得 (First Come First Serve)

This algorithm performs requests in the same order asked by the system. Let's take an example where the queue has the following requests with cylinder numbers as follows:

该算法以系统要求的相同顺序执行请求。 让我们以一个示例为例,其中队列具有以下带有柱面编号的请求,如下所示:

98, 183, 37, 122, 14, 124, 65, 67

98、183、37、122、14、124、65、67

Assume the head is initially at cylinder 56. The head moves in the given order in the queue i.e., 56→98→183→...→67.

假设头部最初在汽缸56处 。 磁头在队列中以给定的顺序移动,即56→98→183→...→67

磁盘调度算法sstf算法_辅助存储和磁盘调度算法

最短搜寻时间优先(SSTF) (Shortest Seek Time First (SSTF))

Here the position which is closest to the current head position is chosen first. Consider the previous example where disk queue looks like,

在此首先选择最接近当前磁头位置的位置。 考虑前面的示例,其中磁盘队列如下所示:

98, 183, 37, 122, 14, 124, 65, 67

98、183、37、122、14、124、65、67

Assume the head is initially at cylinder 56. The next closest cylinder to 56 is 65, and then the next nearest one is 67, then 37, 14, so on.

假设头部最初在汽缸56处 。 下一个最接近的气缸5665,然后下一个最近的一个是67,然后37,14,等等。

磁盘调度算法sstf算法_辅助存储和磁盘调度算法

扫描算法 (SCAN algorithm)

This algorithm is also called the elevator algorithm because of it's behavior. Here, first the head moves in a direction (say backward) and covers all the requests in the path. Then it moves in the opposite direction and covers the remaining requests in the path. This behavior is similar to that of an elevator. Let's take the previous example,

由于其行为,该算法也称为提升算法。 在这里,首先头部朝一个方向移动(例如向后移动)并覆盖路径中的所有请求。 然后,它沿相反的方向移动,并覆盖路径中的其余请求。 此行为类似于电梯的行为。 让我们来看前面的例子,

98, 183, 37, 122, 14, 124, 65, 67

98、183、37、122、14、124、65、67

Assume the head is initially at cylinder 56. The head moves in backward direction and accesses 37 and 14. Then it goes in the opposite direction and accesses the cylinders as they come in the path.

假设头部最初在汽缸56处 。 头部向后移动并进入3714 。 然后,它沿着相反的方向前进,并在圆柱体进入路径时进入圆柱体。

磁盘调度算法sstf算法_辅助存储和磁盘调度算法

翻译自: https://www.studytonight.com/operating-system/secondary-storage

磁盘调度算法sstf算法