4.2.1 · D5Operating Systems
Question bank — OS roles — resource management, hardware abstraction, protection
This page drills the three roles — ==Resource management, Abstraction, Protection== — from the parent note. No arithmetic here; that lives in D3/D4. This is about why the machine behaves as it does.

Keep that image in mind for the edge cases at the bottom.
True or false — justify
The OS runs several programs at exactly the same instant on a single CPU core.
False. One core executes one instruction stream at a time; the OS switches between programs so fast it looks simultaneous. That's concurrency (time-slicing), not parallelism — parallelism needs multiple cores. See CPU Scheduling.
Multiprogramming raises CPU utilization mainly because it makes each program run faster.
False. Each program is not sped up at all — it may even run slower per-program. Utilization rises because while one process waits for I/O, another can use the otherwise-idle CPU.
The OS is just a very big library that programs call into.
False. A library runs with the caller's privileges; the OS runs in a separate, more-powerful CPU mode (Kernel vs User Mode) and owns the hardware. It is a trusted referee, not a helper the app fully controls.
Protection is enforced purely by clever OS software checks.
False. Software alone can be skipped by a malicious program. Enforcement needs hardware — the CPU's mode bit and the MMU physically refuse illegal actions. The OS decides policy; hardware supplies mechanism.
Hardware abstraction exists to make the OS's own code simpler.
Partly true, but that isn't its primary purpose. A uniform interface does aid OS maintainability — driver code is neatly separated from the core. Yet the main driver is portability for applications: the same
read() works on HDD, SSD, or USB. Both benefits are real; the app-facing one is why the abstraction is shaped the way it is.A file is a physical thing that lives on the disk.
False. A file is an abstraction the OS presents over raw sectors/flash blocks. The disk stores bytes in blocks; "file" is the clean interface (
open/read/write/close) layered on top.If a process spends 100% of its time computing (never waits for I/O), adding more processes still boosts utilization a lot.
False. With (never waiting) the idle probability already, so one process alone keeps the CPU 100% busy. Multiprogramming helps because real jobs wait for I/O; without waiting, there's no idle time to reclaim.
User-mode programs can disable the timer interrupt if they really need the CPU.
False. Disabling the timer is a privileged instruction; attempting it in user mode traps to the kernel. This is exactly why one process can never permanently hog the CPU — resource management depends on protection.
Two processes with the same virtual address 0x4000 are reading the same physical memory.
False by default. Each process has its own page table, so the same virtual address normally maps to different physical frames — that's isolation. The one deliberate exception is shared memory: if the OS is explicitly asked to map a region into both processes, their virtual addresses can point at the same physical frame. Isolation is the default; sharing happens only when requested and granted.
Spot the error
"A program calls read(fd, buf, n), so it directly reads the disk sectors itself."
Error: the app never touches the disk.
read is a system call that hands control to the kernel, which walks file system → block layer → driver → controller. The app only sees the contract."A segmentation fault means the disk is full."
Error: a segfault is a memory-protection event — the process touched an address not mapped in its page table, the MMU raised a fault, the OS killed it. It has nothing to do with disk space.
"To switch from user to kernel mode, the program just sets the mode bit itself."
Error: if user code could set its own privilege, protection would be meaningless. The switch happens only through a controlled gate — a trap/syscall instruction or a hardware interrupt — after which the OS, not the app, is running.
"The CPU is idle whenever the currently-running process is waiting for I/O."
Error: only if no other runnable process exists. With multiprogramming the OS schedules another ready process, so the CPU stays busy while one process waits. Idle requires all loaded processes waiting.
"Because the OS abstracts hardware, swapping an HDD for an SSD requires rewriting my program."
Error: it's the opposite — the abstraction exists so your program is unchanged. You swap the driver; the
open/read/write contract stays fixed, so the app doesn't care what device is underneath."Kernel mode is where user programs run their fast code."
Error: user programs run in user mode with restricted instructions. Only the OS runs in kernel mode. Confusing the two erases the protection boundary entirely.
Why questions
Why can't software-only protection ever be trusted?
Because a malicious or buggy program can simply not call the check and jump straight to the forbidden action. Only hardware that refuses at the instruction level (mode bit, MMU) can't be bypassed.
Why does the OS need the timer interrupt specifically?
Without a periodic forced return to the OS, a process that never yields (e.g.
while(1){}) would keep the CPU forever. The timer guarantees control comes back so the scheduler can preempt it.Why is the system call the only legal door into the kernel?
A single, validated entry point lets the OS check every request (arguments, permissions) before acting. Many uncontrolled doors would each be an attack surface; one gate keeps the referee in charge.
Why do the three roles reinforce each other rather than stand alone?
Protection keeps the timer safe so resource management can preempt; abstraction is delivered through the protected syscall gate; and resource management schedules the very abstractions (processes, virtual memory) that abstraction defines. One tension → three interlocking answers.
Why does adding processes give diminishing returns for utilization?
Utilization is , and shrinks geometrically — each extra process multiplies the already-small idle probability by again. So the first few processes recover most of the idle time (steep drop in the figure) and later ones add little (the curve flattens).
Why is a process called a "space + time" abstraction of the CPU?
It bundles a time slice of a CPU core (time-multiplexed via scheduling) with a private address space (space-multiplexed memory). Together they give each program the illusion of its own machine.
Edge cases
If only ONE process is loaded and it never does I/O, what is CPU utilization?
100%. With , . There's no waiting, so the single process keeps the CPU fully busy — multiprogramming would add nothing here.
If a process is purely I/O-bound with exactly (it is always waiting), does multiprogramming ever help?
No. With , for every , so no matter how many such processes you load. The CPU stays busy — the real bottleneck is the I/O device, not the CPU, and adding processes can't reclaim time that never becomes available.
If every loaded process is I/O-bound with close to (but below) , does more multiprogramming save you?
Barely. When is near , stays large even for sizeable , so climbs slowly. You need many processes to reclaim meaningful CPU time — and if hits exactly , you get nothing at all (previous item).
What happens if a process passes a bad pointer (garbage address) into a system call?
The kernel validates the address against the process's page table before using it; an invalid one is rejected (an error return), not blindly dereferenced. This is why syscall argument checking exists — the kernel must never trust user-supplied pointers.
On a machine with no protection hardware (only one CPU mode), can an OS still isolate processes?
Not enforceably. It could ask programs to behave, but any program could touch any memory or hardware. Real isolation requires the dual-mode bit and an MMU; without them, protection is only a polite convention.
Zero processes are loaded — what does the CPU do, and what does the formula say?
The OS runs an idle loop (or halts the core to save power) until an interrupt arrives. Plugging into the formula uses the rule , giving — exactly busy, which matches "no work to do." This is the degenerate boundary of .
When a process is terminated by SIGSEGV, is the other process it tried to read harmed?
No. The MMU blocked the access before any bytes were read, so the target's memory is untouched. Only the offending process dies — that's the whole point of isolation.
Recall One-line summary of the trap pattern
Almost every trap here comes from forgetting one fact ::: hardware, not software, backs the OS — the mode bit, the timer, and the MMU are what make the referee's rules unbreakable.