Introduction to Disk Scheduling Algorithms

1. Introduction

Disk Scheduling In a multiprogrammed computer system, each process may continuously make different requests for read/write operations to the disk. Since sometimes these processes send requests faster than the disk responds, it is necessary to establish a waiting queue for each disk device,

There are four commonly used disk scheduling algorithms:

First Come First Served Algorithm (FCFS),

Shortest Seek Time First Algorithm (SSTF),

Scanning Algorithm (SCAN),

Cyclic Scanning Algorithm (CSCAN)

algorithm

advantage

shortcoming

FCFS algorithm

fair and simple

The average seek distance is large, and it is only used in occasions with less disk I/O

SSTF algorithm

Better performance than " first come first serve "

The average seek time cannot be guaranteed to be the shortest, and there may be a " starvation " phenomenon

SCAN algorithm

Better seek performance to avoid " starvation "

Not conducive to access requests from the end far from the head

C-SCAN algorithm

Eliminates unfairness to track requests on both ends

--



Second, the disk scheduling algorithm

First come first serve algorithm

The FCFS algorithm performs scheduling according to the order in which the process requests to access the disk, which is the simplest scheduling algorithm. The advantage of this algorithm is its fairness. If only a small number of processes need to access, and most of the requests are to access clustered file sectors, it is expected to achieve better performance; but if there are a large number of processes competing to use the disk, the performance of this algorithm tends to be close to random scheduling . Therefore, some more complex scheduling algorithms are considered in actual disk scheduling.

1. Algorithm idea: serve according to the order in which the access requests arrive.

2. Advantages: simple and fair.

3. Disadvantage: The efficiency is not high. Two adjacent requests may cause the innermost to outermost cylinder seek, causing the magnetic head to move repeatedly, which increases the service time and is not good for the machine.

4. Example:

Suppose the disk access sequence: 98, 183, 37, 122, 14, 124, 65, 67. The starting position of the read-write head: 53. Find: the head service sequence and the total head movement distance (tracks).

According to the meaning of the title and the idea of ​​the first-come-first-served algorithm, the head movement trajectory shown in the figure below is obtained. thus:

The head service sequence is: 98, 183, 37, 122, 14, 124, 65, 67

Total head movement distance=(98-53)+(183-98)+|37-183|+(122-37)+|14-122|+(124-14)+|65-124|+(67- 65) = 640 (track)

shortest seek time first algorithm

The SSTF algorithm selects the track that is scheduled to be processed by the track with the closest distance to the track where the current head is located, so as to make each seek time the shortest. Of course, always choosing the minimum seek time does not guarantee a minimum average seek time, but it provides better performance than the FCFS algorithm. This algorithm produces a "starvation" phenomenon.

1. Algorithm idea: The access request closest to the current head is preferentially selected for service, and the seek priority is mainly considered.

2. Advantages: Improved average disk service time.

3. Disadvantage: Some access requests cannot be served after a long wait.

4. Example: For the disk access sequence of the above example, the trajectory of the head movement can be obtained as shown in the figure below.

Scanning Algorithm (aka Elevator Algorithm)

The SCAN algorithm selects the request with the closest distance to the track where the current head is located in the current moving direction of the head as the object of the next service. Since the movement law of the magnetic head is similar to that of the elevator, it is also called the elevator scheduling algorithm. The SCAN algorithm is not fair to recently scanned regions, therefore, it is not as good as the FCFS algorithm and the SSTF algorithm in terms of access locality.

1. Algorithm idea: When the device has no access request, the magnetic head does not move; when there is an access request, the magnetic head moves in one direction, and serves the encountered access requests during the movement process, and then judges whether there is still access in this direction. request, if there is, continue scanning; otherwise, change the direction of movement, and service the passing access request, and so on. As shown below:

Head movement trajectory of scanning algorithm (elevator algorithm)

2. Advantages: Overcome the shortcoming of the shortest seek priority, considering both the distance and the direction.

Cyclic Scanning Algorithm

On the basis of the scanning algorithm, the head moves in one direction to provide service, and when returning, it moves directly to the starting end without serving any request. Since the SCAN algorithm tends to handle access requests that are close to the innermost or outermost tracks, an improved C-SCAN algorithm is used to avoid this problem.

When using the SCAN algorithm and the C-SCAN algorithm, the magnetic head always strictly follows from one end of the disk surface to the other end. Obviously, it can be improved in actual use, that is, the head movement only needs to reach the farthest one. Request can return, Disk endpoints do not need to be reached. This form of SCAN algorithm and C-SCAN algorithm is called LOOK and C-LOOK scheduling. This is because they look for a request before moving in a given direction.

Note that, unless otherwise specified, the SCAN algorithm and C-SCAN algorithm can also be scheduled as LOOK and C-LOOK by default.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326067366&siteId=291194637