Introduction
Imagine many people waiting in line to buy tickets. The problem is how to decide who gets served first so everyone is treated fairly and the process runs smoothly.
Jump into concepts and practice - no test required
Imagine a bakery where customers line up to buy bread. The baker serves each customer in the order they arrived, even if some customers want just one loaf and others want many.
┌───────────────┐
│ Process Queue │
├───────────────┤
│ P1 │
│ P2 │
│ P3 │
│ P4 │
└─────┬─────────┘
│
↓
┌───────────────┐
│ CPU │
│ (Executes P1) │
└───────────────┘processes = [(0, 4), (1, 3), (2, 1)] # (arrival, burst)
completion = []
current_time = 0
for arrival, burst in processes:
if arrival > current_time:
current_time = arrival
completion.append(current_time)
current_time += burst
print(completion)