This repository implements various disk scheduling algorithms in C++ to simulate and compare their performance. The program simulates a disk with 5,000 cylinders and processes 1,000 random cylinder requests using different scheduling algorithms. I made it as a part of programming exercises from Operating Systems Concepts 9th edition book.
- FCFS (First Come First Serve)
- SSTF (Shortest Seek Time First)
- SCAN (Elevator Algorithm)
- C-SCAN (Circular SCAN)
- LOOK (SCAN variation)
- C-LOOK (C-SCAN variation)
Disk-Scheduling-Algorithms/
├── assets/
│ ├── image.png (visualization of the disk scheduling algorithms)
│ ├── visuals.excalidraw (excalidraw file for the visualization)
├── src/
│ ├── main.cpp (contains driver program)
│ ├── DiskScheduler.cpp (class definition and functions implementations)
├── .gitignore
├── README.md
- FCFS: The simplest disk scheduling algorithm. It serves requests in the order they arrive, without any reordering.
- SSTF: Selects the request that is closest to the current head position, minimizing seek time.
- SCAN: The disk arm moves in one direction, servicing all requests until it reaches the end of the disk, then reverses direction.
- C-SCAN: Similar to SCAN, but when the end of the disk is reached, the arm jumps back to the beginning and continues servicing requests in the same direction.
- LOOK: Similar to SCAN, but instead of moving to the end of the disk, the arm reverses direction at the farthest request in each direction, reducing unnecessary movement.
- C-LOOK: Similar to C-SCAN, but instead of jumping to the disk’s beginning, the arm jumps from the highest request to the lowest request and continues servicing in the same direction, avoiding unnecessary trips to the disk extremes.
- The random requests are generated once and used for all algorithms to ensure fair comparison
- Head movement is calculated as the absolute difference between consecutive positions
- The program validates the initial head position (must be 0-4999)
⭐ Star if you find it useful! ⭐
