Questions
Multiple choice and short answer
Try to answer each question before expanding. If you find yourself guessing, return to the relevant lesson.
Question 1
Which of the following is the best one-sentence definition of an operating system?
Show answer
The second choice. An operating system is best defined by its two roles: managing hardware resources (CPU, memory, storage, devices) and providing abstractions (process, file, address space, socket) that make the hardware usable. GUI and firmware are separate concerns; applications are consumers of the OS, not part of it.
Question 2
An operating system is often described as both a resource manager and an extended machine. Which of the following is an example of the extended-machine role?
Show answer
The second choice. The extended-machine role is about hiding hardware complexity behind clean abstractions. A uniform read() call that works on different kinds of I/O object is exactly that — the process sees a convenient abstraction, not the device-specific detail. The other three are resource-management decisions.
Question 3
The transition Running → Ready in the process state model is only possible on systems with:
Show answer
The second choice. Running → Ready is a preemption transition: the kernel takes the CPU away from a process that would prefer to keep running. Without a hardware timer, the kernel only regains control when a process voluntarily yields or blocks, so this transition cannot occur. Multiple CPUs and virtual memory are independent features; preemption exists on uniprocessor systems.
Question 4
Which of these is NOT a typical service provided by an operating system?
Show answer
Rendering HTML is an application concern, not an OS service. The OS provides the abstractions the browser uses — memory, files, network sockets, a display device — but the rendering logic itself lives in the browser. The other three are core services discussed in Lesson 1.3.
Question 5
What is the difference between a system call and a library function?
Show answer
A system call is a request from user space to the kernel to perform a privileged operation. It involves a hardware trap into kernel mode. A library function is an ordinary user-space function that may or may not use system calls internally. For example, printf is a library function; it may call write (a system call) when its buffer fills, but many calls to printf may not trigger a system call at all. In general, one API call can map to zero, one, or many system calls.
Question 6
Which of the following is the primary reason system calls are the only legitimate way for a user program to reach kernel services?
Show answer
The second choice. The CPU's privilege levels (user mode and kernel mode) are enforced by hardware: an attempt to execute a privileged instruction from user mode raises a fault. To reach kernel services, the user program must execute a trap instruction (such as syscall on x86-64), which the hardware routes to the kernel. This is why the system-call interface is the mandatory gateway.
Question 7
What is the difference between a trap and a hardware interrupt?
Show answer
A trap is a synchronous, software-initiated event caused by the currently executing instruction — for example, a system call or a page fault. A hardware interrupt is an asynchronous event caused by an external device — for example, a timer tick, a disk completion, or a network packet. Both switch the CPU into kernel mode and vector to a handler, but the timing and cause differ.
Question 8
Which architectural family places the smallest amount of functionality in kernel mode?
Show answer
The microkernel. It keeps only low-level memory management, IPC, and basic scheduling in kernel mode; everything else — device drivers, file systems, network protocols — runs as user-space server processes. An exokernel is a different design that also minimises kernel functionality but is rarely used in production. Monolithic and hybrid kernels keep much more in kernel mode.
Question 9
What is the fundamental trade-off between monolithic and microkernel architectures?
Show answer
Performance versus isolation. Monolithic kernels place all subsystems in one kernel address space, so operations across subsystem boundaries are function calls — fast, but a bug in any component can bring down the whole system. Microkernels run most subsystems as user-space servers communicating through IPC — safer, because a failed server can be restarted, but slower because IPC is much more expensive than a function call. Modern systems often combine approaches: Linux is monolithic but modular; macOS and Windows use hybrid designs.
Question 10
Which of the following best describes the sequence of stages in the compilation pipeline?
Show answer
Preprocessing → compilation → assembly → linking. Each stage transforms the source file and produces an intermediate artefact (.i, .s, .o), and the linker produces the final executable. The other sequences are not the standard pipeline.
Question 11
What is the purpose of the -g flag to GCC?
Show answer
It tells GCC to include debugging symbols in the executable. These symbols map machine instructions back to source lines and record the names and locations of variables and functions. Without -g, GDB cannot show the source line or variables by name; with it, GDB can step through source lines and print variables symbolically. This is required for the labs and most of the debug sessions in the course.
Question 12
Which of the following commands would let you observe the system calls a program makes?
Show answer
strace. It prints every system call a program makes, with arguments and return values. This is the canonical tool for observing the system-call interface at runtime. GDB is a debugger, make is a build tool, and git is version control.
Question 13
Which historical development first enabled multiple users to interact with a single machine simultaneously?
Show answer
Time-sharing. Batch systems reduced machine idle time by sequencing jobs automatically, but they did not give users interactive access. Time-sharing extended multiprogramming with periodic preemption, giving each user the illusion of a private machine. Personal computing gave each user their own machine; virtualization came later, and enabled multiple operating systems on one machine rather than multiple users on one OS.
Question 14
Why is a virtual machine useful when studying operating systems?
Show answer
Four reasons. Isolation: the VM is separated from the host, so experiments cannot damage the student's real environment. Reproducibility: every student runs the same environment, so commands and outputs match. Safety net: snapshots let you revert to a known-good state after mistakes. Portability: the VM is a set of files that can be copied, backed up, and transferred between machines. These properties make experimentation safe and consistent.
Question 15
What is the main purpose of the .gitignore file in a project's repository?
Show answer
To list files and patterns that Git should ignore. Common entries include compiled binaries (*.o, a.out), build directories, editor swap files, and temporary output. Ignored files are invisible to git status and never committed. This keeps the repository focused on source and configuration.
Question 16
What is the purpose of a Makefile, and why is it better than compiling by hand?
Show answer
A Makefile describes the dependencies between source files and the outputs derived from them. It automates the build process: a single make command compiles only what needs recompiling based on modification times. The advantage over compiling by hand is incremental rebuilds — after changing one source file, only that file and its dependents are rebuilt, not the entire project. A Makefile also documents the exact compiler flags used, ensuring consistent results across developers and machines.
Question 17
Which of the following best describes the distinction between user mode and kernel mode?
Show answer
The second choice. User mode is a hardware-enforced restricted privilege level for application code: it cannot execute privileged instructions or access kernel memory directly. Kernel mode is the fully privileged level in which the OS runs: it has access to all hardware and memory. The CPU raises a fault if user code attempts a privileged operation.
Question 18
Which of the following describes the classical UNIX approach to creating a new process?
Show answer
The second choice. UNIX creates a new process by duplicating the parent with fork, then replaces the child's image with a new program with exec. Windows uses the single-call model (CreateProcess). The UNIX split gives the child a chance to modify its environment between fork and exec — this is what enables redirection, pipelines, and privilege dropping.
Question 19
Why is the operating system described as the "trusted computing base"?
Show answer
Because every security guarantee the system makes depends on the kernel being correct. Isolation between processes, protection of files, enforcement of access control, integrity of the boot chain — all rest on the OS. If the OS is compromised, all guarantees above it are void. This is why the OS is kept as small and as carefully audited as feasible, and why a bug in the kernel is far more serious than a bug in an application.
Question 20
Which of the following is the best reason to prefer a virtual machine over installing Linux directly for a course of this kind?
Show answer
The second choice. Virtual machines provide isolation (the VM cannot damage the host), reproducibility (every student runs the same environment), snapshot capability (revert to a known-good state after mistakes), and portability (the VM is a set of files). These properties make hands-on experimentation with low-level OS concepts safe and reproducible. VMs are generally slightly slower than native installations, not faster.