Posts

Shortest Seek Time First (SSTF) Disk Scheduling

  Shortest Seek Time First (SSTF) Disk Scheduling Aim To simulate the SSTF disk scheduling algorithm and compute the total head movement , displaying Step, From, To, Movement . Theory Shortest Seek Time First (SSTF) selects the disk request that is closest to the current head position . Minimizes immediate seek time Improves performance compared to FCFS May cause starvation for far-away requests Algorithm Read number of disk requests. Read request queue. Read initial head position. Mark all requests as unvisited. From current head: Find request with minimum absolute distance Move head to that request Add movement to total Mark request visited Repeat until all requests are serviced. Program: SSTF Disk Scheduling (C) # include <stdio.h> # include <stdlib.h> int main () { int n, head, total = 0 ; printf ( "Enter number of requests: " ); scanf ( "%d" , &n); int req[n], v...

SCAN Disk Scheduling Algorithm

  SCAN Disk Scheduling Algorithm Aim To simulate the SCAN disk scheduling algorithm and compute the total head movement , displaying Step, From, To, Movement . Theory The SCAN algorithm moves the disk head in one direction first , servicing all requests in its path until it reaches the end of the disk , then reverses direction and services remaining requests. Because the head sweeps back and forth like an elevator, SCAN is also called: 👉 Elevator Algorithm Advantages Better than FCFS in reducing seek time Avoids starvation seen in SSTF Provides more uniform waiting time Disadvantage Requests at extreme ends may wait longer Algorithm Read number of disk requests. Read request queue. Read initial head position. Read disk size. Read direction (LEFT or RIGHT). Sort request queue. If direction = RIGHT: Service all requests greater than head (ascending) Move to disk end Reverse and service remaining smaller requests If dire...

C-SCAN (Circular SCAN) Disk Scheduling Algorithm

  C-SCAN (Circular SCAN) Disk Scheduling Algorithm Aim To simulate the C-SCAN disk scheduling algorithm and compute the total head movement , displaying Step, From, To, Movement . Theory C-SCAN (Circular SCAN) is an improved version of SCAN. The head moves only in one direction (say LEFT → RIGHT). It services all requests while moving in that direction. When it reaches the last track , it jumps to the first track (0) without servicing requests during the return. Then continues again in the same direction. 👉 This provides more uniform waiting time than SCAN. Why C-SCAN? SCAN services requests in both directions, so middle tracks get serviced more often. C-SCAN treats the disk as a circular queue , ensuring fair service. Advantages Uniform waiting time No bias toward middle cylinders Predictable response time Disadvantages Extra head movement due to circular jump Slightly more movement than SSTF Algorithm Read number of disk req...

LOOK Disk Scheduling Algorithm

  LOOK Disk Scheduling Algorithm Aim To simulate the LOOK disk scheduling algorithm and calculate the total head movement with an example. Theory LOOK is an improved version of SCAN. In SCAN , the head moves to the disk end (0 or max track) even if no request exists there. In LOOK , the head only goes as far as the last request in that direction , then reverses. 👉 It “looks ahead” for pending requests before moving further — hence the name LOOK . Key Idea SCAN LOOK Goes to disk end always           Stops at last request Extra unnecessary movement           Avoids unnecessary movement Less efficient           More efficient Algorithm Read disk requests. Read initial head position. Sort the request queue. Choose direction (LEFT or RIGHT). If RIGHT: Service all requests greater than head in ascending order. Reverse direction. Service remaining smalle...

Comparison of Disk Scheduling Algorithms (FCFS, SSTF, SCAN, C-SCAN, LOOK)

  Comparison of Disk Scheduling Algorithms (FCFS, SSTF, SCAN, C-SCAN, LOOK) Aim To implement and compare the disk scheduling algorithms FCFS, SSTF, SCAN, C-SCAN, and LOOK using the same set of disk requests and compute their total head movements . Objectives Understand different disk scheduling techniques Measure total seek movement Compare efficiency of algorithms Theory 1. FCFS (First Come First Serve) Services requests in arrival order Simple but inefficient Can cause large head movement 2. SSTF (Shortest Seek Time First) Selects nearest request from current head Reduces seek time May cause starvation 3. SCAN (Elevator Algorithm) Head moves in one direction servicing requests Goes to disk end, then reverses Better fairness than SSTF 4. C-SCAN (Circular SCAN) Head moves in one direction only After reaching disk end, jumps to start Provides uniform waiting time 5. LOOK Similar to SCAN Does not go to disk en...

Simulation of SSTF, LOOK, and C-SCAN Disk Scheduling

  Simulation of SSTF, LOOK, and C-SCAN Disk Scheduling Aim To simulate SSTF, LOOK, and C-SCAN disk scheduling algorithms for a disk with 5000 cylinders (0–4999) using randomly generated requests, and compute the total head movement for each algorithm. Theory SSTF (Shortest Seek Time First) Selects the request closest to current head position. Minimizes immediate seek time. May cause starvation. LOOK Head moves in one direction servicing requests. Stops at last request, then reverses. Avoids unnecessary movement to disk ends. C-SCAN Head moves only in one direction. After reaching last cylinder, jumps to 0. Provides uniform waiting time. Algorithm Accept initial head position from command line. Generate 10 random cylinder requests (0–4999). Display generated requests. Simulate: SSTF → nearest request each time LOOK → service right then reverse C-SCAN → service right → go to end → jump to 0 → continue Calculate to...