Computer Operating System
Uses operating systems to manage the functionality of computers
Exam objectives
- Define an operating system and briefly describe its evolution
- List the main functions of an OS: providing interfaces, process management, resource management, security
- Classify OS types: single/multi user, single/multi task, multi-threading, real-time, time-sharing
Important areas to cover
- Classify-by-scenario MCQs ("a system controlling a nuclear plant is classified as...") are common
- Listing the four main OS functions is a reliable short-answer question
Lesson content not added yet.
Exam objectives
- Explain file types/extensions, file hierarchy and file systems (e.g. FAT)
- Describe file security (passwords, access privileges) and storage allocation methods: contiguous, linked, indexed
- Explain defragmentation and the need for disk formatting
Important areas to cover
- Comparing contiguous/linked/indexed allocation is a recurring structured question
- Explaining defragmentation with a diagram is common
Lesson content not added yet.
Exam objectives
- Distinguish a process from a program and list the process states
- Draw and explain the seven-state process transition diagram
- Compare long/short/medium-term schedulers and describe the process control block
Important areas to cover
- The seven-state process transition diagram is one of the most consistently examined diagrams in this unit
- Turnaround, response, throughput and waiting time definitions form a frequent short-answer set
Notes
A process is not a program
A program is a file sitting on disk. A process is that program in execution — the code, its data, and a record of how far it has got. Open the same program twice and you have one program and two processes.
The operating system tracks each one in a process control block (PCB), which holds the process id, its current state, the saved contents of the PC and the other registers, its memory limits, its open files and its accounting information. A context switch is the OS saving one PCB and loading another. It is not free, and that cost is the whole argument against a very small time quantum.
The seven states
- New — being created, PCB being set up - Ready — in main memory, has everything it needs except the CPU - Running — actually executing. On a single core, exactly one process - Blocked, also called waiting — waiting for an event such as an I/O completion - Ready/suspend — runnable, but swapped out to disk to free memory - Blocked/suspend — swapped out to disk and still waiting for its event - Exit — finished, resources released
The five-state model leaves out the two suspended states. This syllabus asks for seven, so include them.
The transitions, which is what gets asked
- Ready to running is dispatch, done by the short-term scheduler - Running to ready is a time-out when the quantum expires, or pre-emption by a higher-priority process - Running to blocked is the process requesting I/O - Blocked to ready is the awaited event completing - Ready to ready/suspend, and blocked to blocked/suspend, is the medium-term scheduler swapping a process out to disk - Blocked/suspend to ready/suspend is the event completing while the process is still swapped out - Running to exit is the process finishing
Blocked never goes straight to running. When its event completes it joins the ready queue and waits its turn like everything else.
The three schedulers
- Long-term — decides which jobs are admitted into the system at all, controlling the degree of multiprogramming - Medium-term — swaps processes out to disk and back, which is what creates the two suspended states - Short-term — decides which ready process runs next. Runs most often, so it must be fast
Scheduling algorithms
- First come, first served — runs in arrival order, each to completion. Simple and nobody starves, but one long process at the front delays everything behind it. That is the convoy effect - Shortest job first — picks the shortest of the processes that have arrived. Gives the lowest possible average waiting time, but the burst time has to be known in advance, and a steady supply of short jobs can starve a long one indefinitely - Round robin — each process gets at most one quantum, then goes to the back of the queue. Fair and responsive, which is what makes time sharing work. Too small a quantum and the CPU spends its time context switching; too large and it degenerates into first come, first served - Priority — highest priority runs first. Starves low-priority processes unless their priority rises the longer they wait, which is called ageing
Doing the calculation
- Turnaround time = completion time − arrival time - Waiting time = turnaround time − burst time - Response time = first time on the CPU − arrival time - Average = the total divided by the number of processes
Draw the Gantt chart first and label every boundary time, because every number in the table is read off it. An error in the chart is an error in the entire answer.
For round robin there is one rule that decides whether your chart matches the marking scheme: when a quantum expires, any process that arrived during that quantum joins the ready queue before the process that was just pre-empted rejoins it.
Try it — draw the Gantt chart and read off the averages
Four processes arriving at different times. Switch the algorithm and watch both the chart and the average waiting time change, with the same four processes underneath.
First come, first served. Processes run in the order they arrive, and each runs to completion before the next starts.
P1P2P3P40581618Process Arrival Burst Completion Turnaround Waiting P1 0 5 5 0 P2 1 8 7 4 P3 2 16 14 6 P4 3 18 15 13 Average 10.25 5.75 Turnaround = completion − arrival. Waiting = turnaround − burst. Drag a burst time to see how one long process changes everyone else's wait.
Simple and never starves anyone, but one long process at the front makes everything behind it wait — the convoy effect.
The seven process states, and what moves a process between them
- NewBeing created. Its process control block is being set up and memory is being found for it.Admitted to ready. If main memory is short it can be admitted straight to ready/suspend instead, on disk.
- ReadyIn main memory and waiting its turn. It has everything it needs except the CPU.Dispatched to running when the short-term scheduler picks it, or suspended out to ready/suspend.
- RunningActually executing on the CPU. On a single-core machine exactly one process is here at a time.To ready on a time-out or pre-emption, to blocked on an I/O request, or to exit when it finishes.
- Blocked (waiting)Waiting for an event — a disk read, a key press, a network reply. It could not use the CPU even if it were offered one.To ready when the event completes, or suspended out to blocked/suspend. Never straight to running.
- Ready/suspendRunnable, but swapped out to disk to free main memory. Nothing is stopping it except that it is not resident.Back to ready when it is swapped in (activated).
- Blocked/suspendSwapped out to disk and still waiting for its event. Both things are true at once.To ready/suspend when the event completes while it is still out, or back to blocked if it is swapped in first.
- Exit (terminated)Finished or killed. Its resources are released and its PCB is removed.Nothing leaves this state.
Exam objectives
- Explain the role of the Memory Management Unit and virtual memory (paging)
- Describe how the OS manages I/O devices through device drivers and spooling
Important areas to cover
- Explaining virtual memory/paging is a recurring structured question
- Spooling and device drivers form a common short-answer pair
Lesson content not added yet.