Operating System Principle

First, the main four head scheduling algorithms are introduced.

(1) First Come First Served Algorithm (FCFS)

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)

(2) Shortest Seek Time First Algorithm (SSTF)

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. Ask the students to give the head service sequence and calculate the total head movement distance.

(3) Scanning algorithm (elevator algorithm) (SCAN)

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, 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.

3. Example: The figure below is an example. Ask the students to write out a possible disk access sequence and calculate the total distance of the head movement.

 

Sweep Algorithm Legend

 

(4) One-way scan scheduling algorithm (CSCAN)

Algorithm idea:

1、总是从0号柱面开始向里扫描。

2、按照各自所要访问的柱面位置的次序去选择访问者。

3、移动臂到达最后一个柱面后,立即带动读写磁头快速返回到0号柱面。

4、返回时不为任何的等待访问者服务。

5、返回后可再次进行扫描。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326709070&siteId=291194637