Summary — What This Chapter Covers
- The OS maximises the use of resources (processor, memory, I/O) and hides hardware complexity behind its user interface and system calls.
- A process is a program being executed. Process states: running, ready and blocked.
- Scheduling routines: first come first served, round robin, shortest job first, shortest remaining time.
- The kernel acts as an interrupt handler; interrupts drive low-level scheduling (context switches).
- Paging uses fixed-size pages and frames; segmentation uses variable-size logical segments. Virtual memory uses disk to extend RAM; too much swapping causes disk thrashing.
- An interpreter analyses and runs one statement at a time; a compiler goes through lexical analysis, syntax analysis, code generation and optimisation.
- Grammar is written in BNF or drawn as syntax diagrams.
- Reverse Polish Notation (RPN) needs no brackets and is evaluated with a stack.
1. Purposes of an OS: Resources and the User Interface
16.1
Maximising resources, hiding the hardware
An operating system maximises the use of resources by keeping the processor busy (another process runs while one waits for I/O), allocating memory so that many processes fit, managing I/O devices with buffers, queues and interrupts so slow devices do not hold up the processor, and sharing files and devices safely between users.
The OS hides the complexity of the hardware from the user. The user interface (GUI or command line) lets a user open a file by its name without knowing which disk sectors hold it; device drivers mean the user does not need to know how a particular printer works; and programs request services through system calls (APIs) instead of controlling hardware directly.
Practice Question
Describe two ways in which the user interface hides the complexities of the hardware from the user.
2. Process Management
16.1
Multitasking, states and scheduling
A process is a program that has started executing. Multitasking lets several processes appear to run at the same time: the processor switches rapidly between them, giving each a share of processor time.
| Transition | When it happens |
|---|
| Ready → Running | the low-level scheduler gives this process the processor |
| Running → Ready | its time slice ends (timer interrupt) or a higher-priority process needs the processor |
| Running → Blocked | it must wait for an event such as I/O or a resource |
| Blocked → Ready | the event it was waiting for has happened (for example I/O complete) |
| Not possible | Blocked → Running (it must queue in Ready first); Ready → Blocked (only a running process can request I/O) |
Scheduling is needed so that the processor is used fully, every process gets a fair share, response times are good for interactive users, and high-priority work is done first. The high-level scheduler decides which jobs are loaded into memory; the low-level scheduler decides which ready process runs next.
| Routine | How it works | Benefit | Drawback |
| Round robin |
Memorise