</>
ShikshaCSLearn. Code. Grow.
🔍
☕ Support Us
ShikshaCSâ€ēMini Projects
⌘

CPU Scheduling Simulator

OSIntermediate
CData Structures

💡 Overview

This turns the theory from your OS notes into working code — you'll actually SEE why SJF has lower average waiting time than FCFS, instead of just memorizing it for an exam.

✅ Features to Build

0/4 done

🧭 Step-by-Step Guide

1

Represent each process as a struct: { int pid, arrivalTime, burstTime, waitingTime; }

2

For FCFS: sort processes by arrival time, then calculate each one's waiting time as the sum of burst times before it.

3

For SJF: sort the (already arrived) processes by burst time instead, then calculate waiting times the same way.

4

Sum up all waiting times and divide by the number of processes to get the average.

5

Print a small table comparing FCFS vs SJF average waiting time for the same input.

🚀 Starter Code

struct Process {
  int pid, arrivalTime, burstTime, waitingTime;
};

// After sorting by chosen criteria:
int waitTime = 0;
for (int i = 0; i < n; i++) {
  processes[i].waitingTime = waitTime;
  waitTime += processes[i].burstTime;
}

💡 Pro Tip

Build FCFS completely first and get it 100% correct before adding SJF — reusing a working structure for the second algorithm is much easier than building both at once.

← Back to all Projects