Expt 6 Disk Scheduling Lab
Expt 6 Disk Scheduling Lab
Description
Magnetic disks are made of disk platters. Each disk platter is circular in shape. The read-write heads
lie slightly above each platter. The heads are all attached to a disk arm that moves all the heads as a
unit. The surface of the platter is logically divided into circular tracks. Each track is divided into
sectors. All tracks at one arm position make up a cylinder. A disk drive may have thousands of such
cylinders and each track may contain hundreds of sectors. Seek time is the time necessary to move
the disk arm to the desired cylinder. The time necessary for the desired sector to rotate to the disk-
head is called rotational latency. The access time can be improved by managing the order in which
disk I/O requests are serviced.
Whenever a process needs I/O to or from the disk, it issues a system call to the operating system. If
the desired disk drive and controller are available, the request can be serviced immediately. If the
drive or controller is busy, any new requests for service will be placed in the queue of pending
requests for that drive. For a multiprogramming system with many processes, the disk queue may
often have several pending requests. Thus, when one request is completed, the operating system
chooses which pending request to service next. How the operating system makes the next request
depends on any one of several disk-scheduling algorithms
This is the simplest form of disk scheduling. This algorithm however, does not provide the fastest
service.
Algorithm
1. Create arrays to store track numbers and distances.
2. Read start address of head and save it as the first element of track array.
3. Read remaining track numbers from user and store them in the remaining elements of the
track array.
4. Find the difference between two adjacent elements of track array and store the absolute value
in distance array. Each element of the distance array gives movement distance between two
ordered tracks.
Program
Output
anil@anil-300E4Z-300E5Z-300E7Z:~/System Software lab/expts_program$ ./expt_6_fcfs
b) SCAN
SCAN scheduling
In the SCAN algorithm, the disk arm starts at one end of the disk and moves toward the other end,
servicing requests as it reaches each cylinder, until it gets to the other end of the disk. At the other
end, the direction of head movement is reversed, and servicing continues. The head continuously
scans back and forth across the disk.
Algorithm
2. Read start address of head and save it as the first element of track array.
3. Read remaining track numbers from user and store them in the remaining elements of the
track array.
4. Find the difference between two adjacent elements of track array and store the absolute value
in distance array. Each element of the distance array gives movement distance between two
ordered tracks.
5. Calculate average movement by dividing the sum of movement by number of track movements.
Output
c) C-SCAN
Circular SCAN ( C-SCAN ) scheduling is a variant of SCAN designed to provide a more uniform
wait time. Like SCAN , C-SCAN moves the head from one end of the disk to the other, servicing
requests along the way. When the head reaches the other end, however, it immediately returns to the
beginning of the disk without servicing any requests on the return trip.
Algorithm
2. Read start address of head and save it as the first element of track array.
4. Read remaining track numbers from user and store them in the remaining elements of the
track array.
10. Find the difference between two adjacent elements of track array and store the absolute value
in distance array. Each element of the distance array gives movement distance between two
ordered tracks.
11. Calculate average movement by dividing the sum of movement by number of track movements.
Program
Output