---
title: "CPU simulation with example"
subject: "Simulation and Modeling"
chapter: 10
key: "semester_8/simulation_and_modeling:cpu-simulation-example"
source: https://www.bctengineer.com/q/semester_8/simulation_and_modeling/cpu-simulation-example
site: BCT Engineering
---

# CPU simulation with example

Simulation and Modeling · Chapter 10: Simulation of computer systems

- Asked in: 2074 Bhadra, 6 marks; 2072 Magh, 6 marks; 2071 Bhadra, 6 marks; 2070 Bhadra, 3 marks (asked 4 times)
- Video: [Simulation of Computer Systems | Simulation and Modeling - Crash Course | 04](https://www.youtube.com/watch?v=X5hgJyxuuyE) — AI Stha
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/simulation_and_modeling/cpu-simulation-example
- Whole chapter: https://www.bctengineer.com/md/semester_8/simulation_and_modeling/chapter-10

## Question

Explain CPU simulation with example (sketching a simulation model of a computer system).

## Short answer

CPU simulation uses a queueing model: jobs queue for CPU under a policy like round‑robin. After a burst, jobs may go to disk. Example: arrivals mean 10ms, CPU 6ms, 30% go to disk (5ms). Run to compare quanta 2,4,8ms for best response time.

## Answer

CPU simulation models how a computer's processor handles the workload of jobs. It is done at a high level of abstraction as a **queueing model**: jobs arrive, wait in the ready queue, receive CPU service, use I/O devices, and leave. Its purpose is to estimate CPU utilisation, throughput and response time and to test scheduling policies without changing the real machine.

#### Model components
- **Jobs (entities)**: arrive with an inter-arrival distribution (for example exponential).
- **Ready queue**: jobs waiting for the CPU.
- **CPU (server)**: serves according to the scheduling policy (FCFS, SJF, round robin with quantum q).
- **I/O devices (disk, printer)** with their queues: a job leaves the CPU for I/O and returns.
- **Statistics**: utilisation, mean queue length, response time, throughput.

#### Sketch of the model
```text
 arrivals --> [ready queue] --> (  CPU  ) --> exit
                  ^                |
                  |   quantum      | I/O request
                  |   expired      v
                  +---------- [I/O queue] -> (Disk)
```

#### Logic (round robin, quantum 4 ms)
1. A job arrives; if the CPU is free it starts, otherwise it joins the ready queue.
2. CPU runs it for min(quantum, remaining burst).
3. If it finishes, it leaves. If it needs I/O, it goes to the disk queue and returns to the ready queue later. If the quantum expires, it goes to the back of the ready queue.
4. Events: arrival, CPU burst end, I/O completion.

#### Example
Jobs arrive every 10 ms on average. CPU time per job averages 6 ms; 30% of bursts end in a disk request with service time 5 ms.
- Offered CPU utilisation is about 6/10 = 0.6.
- By running a few thousand simulated jobs, we obtain mean waiting time in the ready queue and disk utilisation.
- The analyst repeats the run with quantum 2, 4 and 8 ms to select the quantum that gives the best response time.

Simulation is preferred when scheduling and I/O interaction make exact analysis difficult.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is CPU simulation modelled at a high level?
   A. As a queueing model of jobs, ready queue, CPU and I/O devices
   B. As a circuit-level model
   C. As a continuous differential model
   D. As a Monte Carlo model without queues
   Answer: A. Jobs arrive, wait in the ready queue, get CPU service, use I/O and leave. (Key point: Model type)

2. In round robin, what happens to a job whose quantum expires without finishing?
   A. It leaves the system
   B. It goes to the back of the ready queue
   C. It goes to the disk queue
   D. It is restarted from zero
   Answer: B. Quantum expiry puts the job at the back of the ready queue; only I/O requests go to the disk. (Key point: Round robin logic)

3. Jobs arrive every 10 ms on average with mean CPU time 6 ms. What is the offered CPU utilisation?
   A. 1.67
   B. 0.4
   C. 0.6
   D. 0.3
   Answer: C. Utilisation = 6/10 = 0.6. (Key point: Utilisation)

4. Why vary the quantum (2, 4, 8 ms) in the simulation?
   A. To change the arrival rate
   B. To reduce disk service time
   C. To verify the code
   D. To select the quantum giving the best response time without altering the real machine
   Answer: D. Simulation tests scheduling policies and parameters to find the best response time. (Key point: Purpose)

## Related in Simulation and Modeling

- [Simulation of computer system serving WWW](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Acomputer-system-www-request) — Simulation and Modeling, chapter 10, asked 2×
- [Continuous system simulation; analog computer example](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Acontinuous-simulation-analog-example) — Simulation and Modeling, chapter 3
- [Define system, model, simulation](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Asystem-model-simulation-define) — Simulation and Modeling, chapter 1
- [Levels of abstraction in computer simulation](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Acomputer-system-abstraction-levels) — Simulation and Modeling, chapter 10
- [CPU simulation at lower abstraction level](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Acpu-lower-level-abstraction) — Simulation and Modeling, chapter 10
- [Analog computer model of the liver](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Aanalog-computer-liver-model) — Simulation and Modeling, chapter 3, asked 5×

## Related in other subjects

- [CPU and IOP communication](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Acpu-iop-communication) — Computer Organization and Architecture, chapter 7, asked 2×
- [General register organization in CPU](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Acpu-register-org) — Computer Organization and Architecture, chapter 2
- [Components of CPU](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Acpu-components) — Computer Organization and Architecture, chapter 2
- [DMA vs CPU memory request](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Adma-vs-cpu-request) — Computer Organization and Architecture, chapter 7
