25-Comp-A5 Operating Systems · May 2015
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer) · Last updated
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
The relationship between CPU utilization and paging-disk utilization traces out a curve against the degree of multiprogramming: as more processes are admitted, both utilizations initially climb together; past a "knee," further multiprogramming makes the page-fault rate explode, paging-disk utilization saturates near 100%, and CPU utilization collapses because processes spend nearly all their time blocked on page-ins rather than computing — this is thrashing. Reading each observed pair against that curve:
(i) CPU 12%, paging disk 5%. No, increasing memory will not raise CPU utilization here. Both figures are low, which is the signature of the left end of the curve, far from the knee — there simply are not enough resident, runnable processes to keep the CPU busy, and since paging activity is already light, memory is demonstrably not the bottleneck. Adding physical memory changes nothing unless it is actually used to admit more work. Change needed: increase the degree of multiprogramming — admit more jobs into memory (or otherwise reduce whatever else is limiting how many processes are ready), rather than simply installing more RAM.
(ii) CPU 10%, paging disk 94%. Yes. A paging disk pinned near saturation while the CPU sits almost idle is the textbook signature of thrashing: the resident processes' combined working sets exceed the frames available to them, so nearly every reference faults and the CPU spends its time waiting on page-ins instead of computing. Increasing physical memory directly attacks the cause — more frames per process shrinks the fault rate, which frees the paging disk and lets the CPU spend its time on useful work instead of servicing faults, raising CPU utilization. (Reducing the degree of multiprogramming, i.e. swapping some processes out entirely, would relieve the same pressure without needing new memory, but the question asks specifically about adding memory, and more memory does resolve it here.)
(iii) CPU 60%, paging disk 60%. Yes, with more modest headroom. A balanced, moderate reading on both axes places the system before the knee, not past it — CPU utilization has room to grow (it is far from saturated at 100%) and the paging load, while non-trivial, is not yet the runaway saturation seen in (ii). Extra memory here lets each resident process retain a larger working set with fewer faults, which should push CPU utilization higher without yet risking thrashing. The caveat is that this is close enough to the middle of the curve that continuing to add multiprogramming without adding memory (or adding too many further processes even with more memory) risks eventually crossing the knee into the (ii)-style collapse.
Given (b). Free list, in list order: 100K, 42K, 205K, 180K, 70K, 91K, 125K, 150K. Jobs arrive strictly in the order Job 1 (120K), Job 2 (104K), Job 3 (204K), Job 4 (88K).
| Hole (in list order) | Size |
|---|---|
| H1 | 100K |
| H2 | 42K |
| H3 | 205K |
| H4 | 180K |
| H5 | 70K |
| H6 | 91K |
| H7 | 125K |
| H8 | 150K |
Find. Which hole each job is allocated to, in arrival order, under (i) best-fit and (ii) first-fit.
Approach. First-fit scans the free list from its head and takes the first hole large enough; best-fit scans the entire free list and takes the smallest hole that is still large enough. After each allocation the used hole's leftover remainder stays in the list, at the same position, as a smaller hole.
| Job (size) | Best-fit allocation | First-fit allocation |
|---|---|---|
| Job 1 (120K) | H7 — 125K hole (5K left over) | H3 — 205K hole (85K left over) |
| Job 2 (104K) | H8 — 150K hole (46K left over) | H4 — 180K hole (76K left over) |
| Job 3 (204K) | H3 — 205K hole (1K left over) | Blocked — no hole $\ge$204K remains |
| Job 4 (88K) | H6 — 91K hole (3K left over) | H1 — 100K hole (12K left over) |