Skip to content

feat(cpu_scheduling): add Round Robin CPU scheduling algorithm - #3268

Open
pruthvi828 wants to merge 1 commit into
TheAlgorithms:masterfrom
pruthvi828:feat/round-robin-cpu-scheduling
Open

pruthvi828 wants to merge 1 commit into
TheAlgorithms:masterfrom
pruthvi828:feat/round-robin-cpu-scheduling

Conversation

@pruthvi828

Copy link
Copy Markdown

Description of Change

This PR implements the Round Robin (RR) CPU Scheduling Algorithm under cpu_scheduling_algorithms/round_robin_scheduling.cpp.

Fixes #1574 (CPU Scheduling algorithms)

Overview

Round Robin is the quintessential preemptive scheduling algorithm used in time-sharing and real-time interactive operating systems. Each ready process is assigned a cyclic time slice (quantum).

Key Features

  • Generic / Templated: Supports generic numerical types for Process ID, Arrival Time, and Burst Time (S, T, E).
  • Comprehensive Lifecycle & Metrics Computation:
    • Completion Time (CT)
    • Turnaround Time (TAT = CT - AT)
    • Waiting Time (WT = TAT - BT)
    • Response Time (RT = FirstCPU - AT)
  • Gantt Chart Timeline Generation: Preserves chronological time windows for execution visualization.
  • Robust Edge Case Handling:
    • Staggered and simultaneous process arrivals.
    • CPU idle gaps when no process has arrived.
    • Zero burst time rejection and duplicate process ID rejection.
    • Degeneracy handling when quantum exceeds total burst times.
  • Doxygen Compliant: Complete Doxygen documentation with @file, @brief, @details, @tparam, @param, and @return tags.
  • Strict Code Style: Verified and formatted with .clang-format (--dry-run --Werror clean).

In-File Self Tests

The implementation includes a complete self-contained test suite (static void test()) with assert():

  1. Canonical Textbook Benchmark: Silberschatz OS Concepts canonical example.
  2. Staggered Arrivals: Processes arriving across varying timeline intervals.
  3. CPU Idle Periods: Large gaps between process arrivals.
  4. Single Process Boundary Case: Verifies turnaround and response invariants.
  5. FCFS Degeneracy: Extremely large quantum behavior.
  6. Input Validation: Rejection of duplicates and invalid burst times.

Checklist

  • Added description of change
  • Added file name matches File name guidelines (cpu_scheduling_algorithms/round_robin_scheduling.cpp)
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Implemented clean, modern, Doxygen-documented Round Robin CPU Scheduling algorithm with Gantt chart generation and self-tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]CPU Scheduling algorithms

1 participant