Assignment 1: Process Scheduling Simulator

Due: Wednesday, February 18, 2026
Upcoming

Submission Guidelines

Languages

C
C++
Python

Time Limit

2 seconds

Memory Limit

256 MB

Problem Description

Overview

In this assignment, you will implement a CPU Scheduling Simulator that supports multiple scheduling algorithms. Your program will read a list of processes with their arrival times, burst times, and priorities, then simulate the specified scheduling algorithm and output the results.

Supported Algorithms

Your simulator must support the following scheduling algorithms:

  1. FCFS (First-Come, First-Served) - Non-preemptive
  2. SJF (Shortest Job First) - Non-preemptive
  3. RR (Round Robin) - Preemptive with configurable time quantum
  4. PRIORITY - Non-preemptive priority scheduling (lower number = higher priority)

Input Format

The first line contains the algorithm name and optional parameters:

  • FCFS
  • SJF
  • RR <quantum> (e.g., RR 2)
  • PRIORITY

The second line contains an integer n, the number of processes.

The next n lines each contain process information:

<process_id> <arrival_time> <burst_time> <priority>

Output Format

Output the execution order as process IDs separated by spaces, followed by two lines:

  • Average Waiting Time (rounded to 2 decimal places)
  • Average Turnaround Time (rounded to 2 decimal places)

Example

Input:

FCFS
3
P1 0 5 1
P2 1 3 2
P3 2 8 1

Output:

P1 P2 P3
Average Waiting Time: 4.33
Average Turnaround Time: 9.67

Constraints

  • 1 ≤ n ≤ 1000
  • 0 ≤ arrival_time ≤ 10000
  • 1 ≤ burst_time ≤ 1000
  • 1 ≤ priority ≤ 100
  • For Round Robin: 1 ≤ quantum ≤ 100

Hints

  • For FCFS and SJF, use a queue/priority queue based on arrival time and burst time
  • For Round Robin, maintain a ready queue and track remaining burst times
  • Handle ties by process ID (lexicographic order)
  • Be careful with floating-point precision in your average calculations

Sample Test Cases

Use these examples to test your solution before submitting

Basic FCFS

Input

FCFS
3
P1 0 5 1
P2 1 3 2
P3 2 8 1

Expected Output

P1 P2 P3
Average Waiting Time: 4.33
Average Turnaround Time: 9.67

Round Robin

Input

RR 2
4
P1 0 5 1
P2 0 4 1
P3 0 2 1
P4 0 1 1

Expected Output

P1 P2 P3 P4 P1 P2 P1 P2
Average Waiting Time: 6.50
Average Turnaround Time: 9.50