OS resource management and processes
Sharing the computer's resources
- Many programs compete for the CPU, memory, disk and I/O.
- The OS shares them fairly and efficiently so the system stays responsive.
- It manages each program as a process.
Maximising resource use
- Multi-tasking — switch the CPU quickly between processes so several seem to run at once.
- Memory management — give each process memory; page to disk when RAM runs out.
- Spooling — print jobs queue on disk, so the CPU never waits for the slow printer.
- Caching — keep recently-used data in fast cache/RAM.
Practice
Multi-tasking lets several programs appear to run at once by:
The OS rapidly switches the single CPU between processes so they all seem to progress together.
Practice
Spooling helps the system because:
Spooling buffers print jobs to disk so the fast CPU is not held up by the slow printer.
Process scheduling
- A process is a program in execution (its code, state, memory, open files).
- The scheduler picks which ready process runs next, and for how long.
- Round robin gives each process a fixed time slice, then sends it to the back of the queue (responsive and fair).
Practice
Round-robin scheduling gives each process:
Each ready process runs for a fixed time slice in turn — fair and responsive.
Process states and context switching
- A process is new, ready (waiting for the CPU), running, blocked (waiting for I/O), or terminated.
- Running → ready when its slice ends; running → blocked when it requests I/O; blocked → ready when the I/O finishes.
- Switching process means saving one's state to its process control block (PCB) and restoring another's — a context switch (a small cost each time).
Practice
A process enters the "blocked" state when it:
A process blocks while waiting for I/O; when the I/O completes it returns to ready.
Practice
A context switch involves:
The OS saves the running process's registers/PC to its PCB and loads the next process's — a small overhead each switch.
You've got it
Key idea
- the OS maximises resources via multi-tasking, paging, spooling and caching
- a process is a running program; the scheduler chooses the next ready one (round robin = time slices)
- states: new → ready → running, with blocked for I/O, then terminated
- a context switch saves/restores state via the PCB