Operating system (8) The structure of the disk, the track, the disk sector, and the disk scheduling algorithm to reduce the delay time of the disk.

Disk management

One, the structure of the disk

1. Disks, tracks, sectors

Insert picture description here

2. How to read and write data on the disk

You need to move the head to the track where the sector you want to read and write is located, and the disk will rotate so that the target sector will be swiped under the head to complete the read and write operations on the disk.

3. The physical address of the disk

Insert picture description here
Insert picture description here

4. Knowledge review

Insert picture description here

Second, the disk scheduling algorithm

1. The time required for a disk read and write operation

Time required = seek time + delay time + transmission time

(1) Seek time: the time it takes to move the head to the specified track before reading and writing data

(2) Delay time: the time required to position the head to the beginning of the target sector by rotating the disk

(3) Transmission time: the time that the disk rotates and reads and writes data from the target sector of the disk

2. First come first served (FCFS)

Scheduling according to the sequence of process requests to access the disk
Insert picture description here

3. Shortest search time first (SSTF)

The priority track is the track closest to the current head
Insert picture description here

Advantages: good performance, short average seek time.
Disadvantages: the head may move back and forth in a small area, which may cause starvation.

4. Scanning Algorithm (SCAN)

The head can only move inward when it moves to the outermost track, and can move outward when it moves to the innermost track.

Insert picture description here

Disadvantages:

(1) The head movement direction can only be changed when it reaches the outermost side. In fact, after the 184 access is completed, you can return without accessing 200 tracks. You can use the LOOK algorithm to solve this problem: if there is no other request in the head movement direction , You can immediately change the head movement direction

(2) The response frequency of each position of the track is not even: the one that is close to the end point will be accessed a second time soon

5. Cyclic Scan Algorithm (SCAN)

The track access request is processed only when the head moves in the specified direction, and when it returns, it moves directly to the beginning without processing any request

Insert picture description here

Disadvantages: no need to move to the right end to return to the beginning, you can use the C-LOOK algorithm to solve this problem

6. Knowledge review

Insert picture description here

3. Ways to reduce disk latency

  1. The head needs a short period of time after reading the data of a sector, that is to say, it cannot read the next adjacent sector continuously after reading a sector.

  2. Ways to Reduce Delay Time-Alternate Numbering

Let logically adjacent sectors have a certain physical interval
Insert picture description here

  1. Ways to reduce delay time-misplaced naming

The sector numbers are misplaced and named at the same relative position on adjacent disks

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49343190/article/details/111790640