Chapter 1: Introduction
Multiple Choice · Introduction
Question 1: Which Is Not the OS’s Job?
A student says, “everything that happens on a computer is done by the operating system.” Which of the following tasks belongs to a separate application program rather than to the operating system?
C: A compiler (e.g. gcc) is an ordinary program running in user mode; the OS only gives it CPU, memory and file services. A is process management, B the file system, D memory protection: all three are the kernel’s job.
Multiple Choice · Position and Modes
Question 2: Privileged Instruction in User Mode
A program running in user mode tries to execute a privileged instruction that disables interrupts. What happens?
B: The CPU checks the mode bit; a privileged instruction in user mode raises an exception and control passes to the kernel’s handler. The process is typically terminated with a signal and the rest of the system is unaffected. With D, protection would be meaningless: kernel mode is entered only through system calls, interrupts and exceptions.
Classic Question · Position and Modes
Question 3: Which Ones Enter the Kernel?
Which of the following events cause the CPU to switch from user mode to kernel mode? Give a short reason for each.
(a) x = y * 2; (b) read(fd, buf, 100); (c) a division by zero
(d) strlen(s); (e) a hardware timer interrupt
Show answer
- (b) switches: it is a system call; the libc wrapper deliberately raises a trap with the
syscallinstruction. - (c) switches: an exception caused by the instruction itself; the kernel’s handler runs (usually the process is terminated with a signal).
- (e) switches: a hardware interrupt from outside; the kernel takes control back and the scheduler may run.
- (a) and (d) do not switch: a register/ALU operation and library code that counts a string in memory; both stay entirely in user mode.
There are only three doors from user mode into the kernel: system call, interrupt, exception.
Multiple Choice · Roles of the OS
Question 4: Who Hides the Disk Details?
A programmer can write to a file with write(fd, buf, n) without knowing how many platters the disk has or which controller it uses. Which OS role makes this possible?
A: A file is an abstraction built on top of block and sector details; here the OS acts as the extended machine that turns “ugly hardware into a beautiful abstraction.” The resource-manager role instead decides who uses the CPU, memory and devices, and how much.
Classic Question · Roles of the OS
Question 5: Time or Space?
As a resource manager the OS shares resources in two ways: in time (taking turns) or in space (dividing into parts). How are the CPU, main memory, a shared printer and the disk shared? Write one sentence for each.
Show answer
| Resource | Way | How? |
|---|---|---|
| CPU | time | Processes take turns receiving time slices (time sharing). |
| Main memory | space | Each process gets its own region (frames); all of them are in memory at the same time. |
| Printer | time | Jobs are printed one at a time, as a whole, from the spooling queue. |
| Disk | space (+ time) | Files get separate blocks; read/write requests are scheduled in turn. |
Indivisible resources (CPU, printer) are shared in time; divisible ones (memory, disk space) in space.
Step-by-Step Trace · History
Question 6: Multiprogramming Timeline
Two jobs run on a single-CPU multiprogrammed system (unit time). When does each job finish, and what is the CPU utilization? What would happen if the same jobs ran one after another on a uniprogrammed system?
At the start both jobs are ready; the CPU goes to A first.
A uses the CPU for two units; B waits in the ready state.
When A moves to I/O the CPU does not sit idle but goes straight to B. A’s I/O overlaps B’s computation.
At t = 5, A’s I/O ends and B moves to I/O: the CPU returns to A. A finishes at t = 7.
B’s I/O had ended at t = 7; B runs its last two units. Both jobs finish in 9 units; the CPU was never idle (100%).
On a uniprogrammed system the CPU waits for the job’s own I/O: the same jobs take 14 units and the CPU is idle for 5.
Job A: CPU 2 → I/O 3 → CPU 2 Job B: CPU 3 → I/O 2 → CPU 2 When the CPU is free, the first ready job is chosen; A goes first. A job doing I/O does not need the CPU; the jobs use separate devices.
Multiple Choice · History
Question 7: What Time Sharing Adds
Which property is the key difference between time sharing and multiprogramming?
D: In time sharing a process loses the CPU when its slice expires, even if it does no I/O; the goal is short response time for many users. A and B are multiprogramming itself (the switch happens when a job starts waiting); C belongs to batch systems.
Classic Question · Hardware
Question 8: How Many Clock Cycles Is the Wait?
On a core running at 3 GHz, how long is one clock cycle in ns? How many clock cycles does a DRAM read (~80 ns), an NVMe SSD read (~50 µs) and a hard-disk read (~5 ms) correspond to? How does the OS make use of this gap?
Show answer
1 cycle = 1 / (3 × 10⁹) s ≈ 0.33 ns; 3 cycles pass in 1 ns.
| level | time | clock cycles |
|---|---|---|
| DRAM | 80 ns | 80 × 3 = 240 |
| NVMe SSD | 50 µs = 50,000 ns | 150,000 |
| HDD | 5 ms = 5,000,000 ns | 15,000,000 |
Hardware caches hide DRAM waits; it is not worth the OS stepping in. Disk and SSD waits reach hundreds of thousands to millions of cycles, so the OS blocks the process and runs another one meanwhile (multiprogramming).
Multiple Choice · Hardware
Question 9: Number of Logical CPUs
Each core of an 8-core processor runs two hardware threads (SMT, Hyper-Threading). How many logical CPUs does the operating system see?
B: SMT presents each core to the OS as two logical CPUs: 8 × 2 = 16. Because two hardware threads share the same core’s execution units and cache, these 16 CPUs are not as fast as 16 separate cores; this is why the scheduler uses idle physical cores first.
Multiple Choice · I/O
Question 10: Which One Is a Trap?
Which of the following events is not an interrupt from an external device but a trap (exception) caused by the executing instruction itself?
B: A trap is synchronous: it is the result of a specific instruction and occurs at the same point with the same input every time (division by zero, invalid memory access, page fault, system call). The other three are asynchronous hardware interrupts independent of the instruction stream.
Classic Question · I/O
Question 11: Interrupt-Driven I/O vs. DMA
64 KiB of data is read from a device. With interrupt-driven I/O, one interrupt occurs for every 8 bytes and each interrupt costs the CPU 1.5 µs. With DMA, the CPU programs the controller in 4 µs and a single interrupt (1.5 µs) arrives at the end of the transfer. How much CPU time does each method spend?
Show answer
- 64 KiB = 64 × 1024 = 65,536 B (KiB is a binary prefix).
- Interrupt-driven: 65,536 / 8 = 8192 interrupts → 8192 × 1.5 µs = 12,288 µs ≈ 12.3 ms.
- DMA: 4 + 1.5 = 5.5 µs.
The CPU load drops by a factor of about 2200; while the transfer runs, the CPU executes other processes. For slow devices such as a keyboard the difference is negligible; for fast block devices DMA is essential.
Multiple Choice · I/O
Question 12: What DMA Does Not Give
DMA support was added to a disk controller. Which of the following is not a benefit provided by DMA?
D: DMA is a performance mechanism that takes the copying load off the CPU. It brings no security; on the contrary, a device that writes directly to memory can corrupt anything if misprogrammed. Limiting device access takes an IOMMU in addition.
Multiple Choice · OS Types
Question 13: Hard Real-Time System
Which of the following is a hard real-time system?
C: An airbag missing its deadline is a disaster; an RTOS bounds the worst-case latency. Video and games tolerate occasional missed deadlines and are soft real-time; a web server is a general-purpose system that stresses average performance and fairness. Real-time means “predictable,” not “very fast.”
Multiple Choice · Key Concepts
Question 14: Policy or Mechanism?
Which of the following is a policy decision rather than a mechanism?
B: Whom to prioritize answers the “what should be done” question; the same priority-scheduler mechanism can be used with different policies. A, C and D are mechanisms that provide how the work is done. If the two are kept separate, the policy can be changed without changing kernel code.
Multiple Choice · Key Concepts
Question 15: Why Does the Disk Look Smaller?
A new disk labeled “2 TB” shows up as roughly how many GiB in an operating system that displays sizes with binary prefixes (GiB)?
A: Disks are measured in decimal: 2 TB = 2 × 10¹² B. 1 GiB = 2³⁰ = 1,073,741,824 B → 2 × 10¹² / 2³⁰ ≈ 1862.6 GiB (≈ 1.82 TiB). D comes from dividing by 1024 only once, and C from assuming “1 TB = 1024 GB.” Memory is usually measured in binary, disks and networks in decimal.