Coursework extension · Operating systems

CPU Scheduling Simulation

A Java simulation comparing First Come First Served (FCFS) and Shortest Job First (SJF) scheduling, analysing waiting time, turnaround time and response time as system load increases.

Stack
Java, threads, blocking queues, CountDownLatch
Context
Operating Systems coursework, extending a provided starter codebase
My work
Scheduling policies, coordinated startup, metric collection, file logging and repeated experiments

The simulation

Running, and measured.

I ran the simulation locally at four load levels for each algorithm.

Terminal output of an SJF run with 10 patrons
A runPatrons arrive, submit orders and wait, while the barman serves them in the order the chosen policy picks.
Table comparing FCFS and SJF mean turnaround and waiting time at 10, 20, 40 and 60 patrons
FCFS vs SJFSimilar at low load. At 40 and 60 patrons SJF's mean turnaround and waiting times were roughly 14–18% lower, in line with the expected behaviour as load grows.

Model

A single-server system.

Patrons

Processes arriving over time at staggered intervals.

Drink orders

Individual units of work, equivalent to CPU bursts.

The barman

The CPU, serving one order at a time.

The shared queue

The ready queue. The scheduling policy is chosen at runtime.

Scheduling policies

What I added to the provided code

Limitations, stated up front. Single-server only, no preemption, no context-switch overhead, and no mitigation of starvation under SJF.