100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is the C-SCAN Disk Scheduling Algorithm?

Learn how C-SCAN disk scheduling works, its uniform wait-time benefit vs SCAN, and how to implement it, with OS interview questions.

mediumQ115 of 224 in Operating Systems Est. time: 6 minsLast updated:
Open Code Lab

Expected Interview Answer

C-SCAN (Circular SCAN) services disk requests by sweeping the head in one direction only to the end of the disk, then jumping immediately back to the starting edge without servicing any requests on the return trip, giving every cylinder a more uniform wait time than plain SCAN.

The head moves toward the highest-numbered cylinder, servicing every pending request it passes along the way, exactly like SCAN. Once it reaches the last cylinder (or the highest requested one), instead of reversing direction and servicing requests on the way back, it does a fast, non-servicing return to cylinder 0 and then starts a fresh sweep upward. This circular treatment means the disk is logically treated as a ring, so cylinders near the low end never have to wait through two full sweeps as they would under plain SCAN โ€” every cylinder gets serviced once per rotation of the arm. The tradeoff is the wasted seek time on the return jump, but that cost is repaid with much more even, predictable response times across the whole disk, which matters for workloads sensitive to worst-case latency rather than raw average seek time.

  • Gives uniform wait time across all cylinders, unlike SCAN
  • Avoids favoring middle cylinders over edge cylinders
  • Predictable, bounded worst-case wait time per request
  • Simple circular extension of the well-understood SCAN algorithm

AI Mentor Explanation

C-SCAN is like a groundstaff member mowing stripes only in one direction across the outfield, from boundary to boundary, and then walking back empty-handed to the starting boundary before mowing the next stripe the same way. Every strip of grass gets exactly one pass per lap, rather than some strips getting mowed twice while others wait two full laps. The empty walk-back costs time, but it keeps the whole outfield equally tidy instead of the middle looking better than the edges.

Step-by-Step Explanation

  1. Step 1

    Sweep upward

    The head moves from its current cylinder toward the highest-numbered cylinder, servicing every request it passes.

  2. Step 2

    Reach the edge

    On reaching the last cylinder (or highest pending request), the sweep stops servicing new requests.

  3. Step 3

    Jump back

    The head performs a fast return to cylinder 0 without servicing any request along the way.

  4. Step 4

    Repeat the sweep

    A new upward sweep begins from cylinder 0, servicing requests exactly as before, forming a circular pattern.

What Interviewer Expects

  • A clear description of the one-direction sweep plus non-servicing return jump
  • Comparison against SCAN to explain why C-SCAN is fairer
  • Awareness that the return jump adds seek overhead
  • Recognition that C-SCAN targets uniform wait time, not minimal average seek time

Common Mistakes

  • Claiming C-SCAN services requests on the return trip like SCAN does
  • Confusing C-SCAN with C-LOOK, which only travels to the last real request, not the physical edge
  • Assuming C-SCAN always has a lower average seek time than SCAN
  • Forgetting that C-SCAN treats the disk as circular, wrapping from the highest cylinder to zero

Best Answer (HR Friendly)

โ€œC-SCAN moves the disk head in one direction, servicing requests along the way, then jumps straight back to the starting edge without stopping for anything, before sweeping forward again. It costs some extra travel time on that jump back, but it makes sure every part of the disk gets serviced at a fair, predictable interval instead of some areas being favored over others.โ€

Code Example

C-SCAN disk scheduling simulation
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b) {
    return (*(int *)a - *(int *)b);
}

/* requests[] must be sorted ascending before calling */
void c_scan(int requests[], int n, int head, int disk_size) {
    qsort(requests, n, sizeof(int), cmp);

    int total_seek = 0;
    int current = head;

    /* find split point: requests >= head go first, in order */
    int i = 0;
    while (i < n && requests[i] < head) i++;

    /* service upward toward the end of the disk */
    for (int j = i; j < n; j++) {
        total_seek += abs(requests[j] - current);
        current = requests[j];
    }

    /* jump to the far edge, then wrap to the start (non-servicing) */
    total_seek += abs((disk_size - 1) - current);
    total_seek += (disk_size - 1);   /* wrap-around cost to cylinder 0 */
    current = 0;

    /* service the remaining lower requests, moving upward again */
    for (int j = 0; j < i; j++) {
        total_seek += abs(requests[j] - current);
        current = requests[j];
    }

    printf("Total seek movement (C-SCAN): %d\n", total_seek);
}

Follow-up Questions

  • How does C-SCAN differ from plain SCAN in handling the return trip?
  • How does C-LOOK improve on C-SCAN by avoiding the trip to the physical disk edge?
  • Why does C-SCAN give more uniform wait times than SCAN?
  • In what workload would C-SCAN be preferred over SSTF?

MCQ Practice

1. What does the disk head do after reaching the last cylinder in C-SCAN?

C-SCAN performs a fast, non-servicing return to the starting edge before beginning a new one-directional sweep.

2. Why is C-SCAN considered fairer than plain SCAN?

By always sweeping in one direction and wrapping around, C-SCAN avoids the uneven waits SCAN causes near the disk edges.

3. What is the main cost introduced by C-SCAN compared to SCAN?

The jump back across the disk without servicing requests adds extra seek time that SCAN avoids by servicing on both directions.

Flash Cards

What is C-SCAN? โ€” A disk scheduling algorithm that sweeps one direction, then jumps back to the start without servicing requests, and sweeps again.

How does C-SCAN differ from SCAN? โ€” SCAN services requests in both directions; C-SCAN only services in one direction and jumps back non-servicing.

What does C-SCAN optimize for? โ€” Uniform wait time across all cylinders rather than minimal average seek time.

What is the main downside of C-SCAN? โ€” The non-servicing return jump adds extra seek overhead.

1 / 4

Continue Learning