# Disk Scheduling in Operating System

In this tutorial, we will learn about disk scheduling in operating system, disk scheduling algorithms, and the best way to select disk scheduling algorithms. By Abhishek Kataria Last updated : May 07, 2023

## What is Disk Scheduling in Operating System?

One of the major duties of the operating is that, to use the hardware orderly and accurately. For disk drives, it has a duty of having a fast access time and disk bandwidth. Generally, bandwidth is the total number of bytes, which need to be transferred, and then divided by the total time between the first service and the last transfer. In the case of disk structure, we have to improve both access time and the bandwidth with the help of scheduling the service of disk I/O requests in good order. By this there are many techniques comes for disk scheduling which is prescribed below.

## What are the Disk Scheduling Algorithms?

The following are the disk scheduling algorithms:

### 1. FCFS Scheduling Algorithm

This is a simple scheduling algorithm which means first come first serve form of an algorithm. This kind of algorithm generally not provides the fastest service.

Consider the example: a disk queue with a request for I/O to blocks on cylinder 97, 182, 37, 128, and 15 in that order. If the disk head is initially at cylinder 52, so it will first move from 52 to 97, then 182, 37, 128, 15. There is a drastic change in the moment like 37 to 128 and then back to 15, it can generate the problem with this schedule.

### 2. SSTF Scheduling Algorithm

This is an algorithm which is termed as shortest seek time first algorithm. This type of algorithm selects the request with the minimum seek time from the current head position, as seek time is a time in which the arm has to move the head to the cylinder containing the desired sector. Seek time will be increased if the number of the head will be traversed by the head, as SSTF choose the request closest to the head position.

### 3. SCAN Scheduling Algorithm

SCAN scheduling algorithm is also called the elevator algorithm because in such kind of algorithm arm behaves just like an elevator for building the way. In the SCAN algorithm, the arm will start at the one end of the disk and then move towards another end of the disk. At the last end, the head of the arm will be reversed and then this process continues.

### 4. C-SCAN Scheduling Algorithm

This kind of algorithm is termed as circular scan scheduling algorithm. This is designed to provide a uniform wait time. The C-SCAN algorithm treats the cylinder as the circular lists which will wrap the final cylinder to the first one. Although it is same as SCAN, in this also the head will move from one end to the another, when the head reaches the end it immediately return at a position of the beginning of the disk, without any request.

### 5. LOOK Scheduling Algorithm

This is the same as a SCAN algorithm, this algorithm kindly check the LOOKS to see whether there is any request which is pending in the direction of a head moment. Generally, according to the LOOK algorithm, the arm goes only as far as possible in each direction and then reverse direction without going to the end. The variant like scan is called LOOK scheduling because at last, they will look for a request before to move in a given direction.

## Selection of a Disk Scheduling Algorithms

SSTF is a common algorithm which will increase the performance over the FCFS. SCAN and C-SCAN perform better for the system which places a heavy load on the disk because there is no such kind of a starvation problem. For any kind of the algorithm, the performance is basically dependent upon the number and the type of the requests. Disk scheduling algorithm should be written separately so that it can be replaced by a different algorithm if necessary. In this case, SSTF or LOOK is the best choice for the shortcoming algorithm.