Chapter 38 Quiz: Capstone — A Minimal OS Kernel
Instructions: Choose the best answer. ⭐ marks questions with answers in Appendix B.
Question 1 ⭐ Why must the A20 address line be explicitly enabled in a bootloader?
A) A20 controls access to memory above 64KB B) For historical IBM PC compatibility, the A20 line is gated off by default, wrapping addresses at 1MB; enabling it allows access to the full 32-bit (or 64-bit) address space C) A20 is required for 64-bit long mode to function D) A20 enables the second CPU core in SMP systems
Question 2 In the MinOS boot sequence, which CPU mode does the bootloader start in?
A) 32-bit protected mode B) 64-bit long mode C) 16-bit real mode D) System Management Mode (SMM)
Question 3 ⭐ What is the purpose of the TSS (Task State Segment) in 64-bit x86?
A) It stores the current task's floating-point registers B) It holds the kernel stack pointer (RSP0) used when transitioning from ring 3 to ring 0 on interrupts or system calls C) It manages context switching between processes automatically D) It stores the GDT and IDT base addresses
Question 4
The VGA text buffer is at physical address 0xB8000. Each character cell is 2 bytes. The offset for character at column 5, row 3 of an 80-column display is:
A) 5 × 3 × 2 = 30 B) (3 × 80 + 5) × 2 = 490 C) 3 × 80 × 2 + 5 = 485 D) (3 + 5 × 80) × 2 = 806
Question 5 ⭐
In x86-64, what does the iretq instruction do?
A) Jumps to a system call handler
B) Pops RIP, CS, RFLAGS, RSP, and SS from the stack and restores them, returning from an interrupt
C) Returns from a CALL instruction, popping the return address
D) Loads the IDT from the address pointed to by the operand
Question 6 The PIT (Programmable Interval Timer) is initialized at 100Hz. The base clock frequency is 1,193,182 Hz. What divisor is loaded into the PIT?
A) 100 B) 1193 C) 11932 D) 119318
Question 7 ⭐ In a preemptive round-robin scheduler, when does a context switch occur?
A) Only when the current process voluntarily calls yield()
B) On every timer interrupt
C) After a fixed number of timer ticks (a timeslice) have elapsed
D) When the current process exits
Question 8 The physical memory bitmap allocator uses 1 bit per 4KB page. How many bytes of bitmap are needed to track 256MB of physical memory?
A) 256 bytes B) 8,192 bytes (8KB) C) 65,536 bytes (64KB) D) 1,048,576 bytes (1MB)
Question 9 ⭐ In the MinOS context switch, why is the kernel thread's context saved by the interrupt handler rather than by explicit scheduler code?
A) The CPU automatically saves all registers on every interrupt
B) The interrupt handler pushes all general-purpose registers before calling the scheduler; when iretq restores the new process's saved state, the context switch completes
C) The scheduler uses the XSAVE instruction to save all processor state
D) Context is saved by the BIOS between each interrupt
Question 10
What does pic_eoi(0) do at the end of an IRQ handler?
A) Enables IRQ 0 in the PIC mask B) Sends an End of Interrupt signal to the PIC, allowing future IRQ0 interrupts to be delivered C) Resets the PIT timer D) Decrements the interrupt count for IRQ 0
Question 11 ⭐
Why is mno-red-zone a required GCC flag when compiling kernel code?
A) The red zone (128 bytes below RSP) is used by signal handlers, which may overwrite it
B) In kernel mode, interrupts can occur at any time and the interrupt handler uses the stack below RSP; the red zone optimization would cause the interrupt handler to corrupt kernel data
C) The red zone is not supported in 32-bit code
D) mno-red-zone enables a different calling convention required for kernel functions
Question 12
The kernel uses ffreestanding when compiling. What does this flag do?
A) Disables floating-point instructions B) Tells GCC that the standard C library is not available, preventing it from generating code that calls library functions C) Enables free (unconstrained) stack frame optimization D) Disables position-independent code generation
Question 13 ⭐ When the IDT is set up with the PIC remapped so that IRQ0 = vector 0x20, what is the vector for the keyboard interrupt (IRQ1)?
A) 0x01 B) 0x20 C) 0x21 D) 0x41
Question 14
In MinOS Track C, why does user-mode code need to use SYSCALL/SYSRET or INT 0x80 to request kernel services rather than calling kernel functions directly?
A) Kernel functions use a different calling convention than user code B) User mode runs at privilege level 3 and cannot execute privileged instructions or access kernel memory; system calls switch to kernel mode with proper privilege C) User mode processes have a separate stack that cannot call kernel stacks D) The kernel is loaded at addresses unreachable from user mode
Question 15 ⭐
When kernel_main() calls hlt in its idle loop, what wakes the CPU?
A) Nothing; hlt permanently halts the processor
B) Any pending interrupt (timer, keyboard, etc.) wakes the CPU from hlt and delivers the interrupt
C) Only a RESET signal wakes the CPU from hlt
D) The scheduler automatically wakes the CPU after 10ms
Question 16 In the MinOS GDT, what is the difference between selector 0x08 (kernel code) and 0x18 (user code)?
A) Kernel code is read-only; user code is readable and writable B) They have different privilege levels (DPL): kernel code has DPL=0, user code has DPL=3 C) Kernel code uses 32-bit mode; user code uses 64-bit mode D) User code segment includes a different base address for ASLR
Question 17 ⭐ In 64-bit long mode, the GDT base and limit values in code and data descriptors are mostly ignored. What remains significant?
A) The base and limit are still fully enforced in long mode B) The L bit (64-bit mode), the DPL (privilege level), the P bit (present), and the type bits remain significant; base/limit are ignored for code/data (but not for the TSS) C) Only the DPL and present bit matter; all other bits are ignored D) Segment descriptors have no effect in long mode; paging alone controls access
Question 18
What is the truncate -s 1474560 minOS.img command in the Makefile doing?
A) Verifying that the image file is not corrupted B) Padding the disk image to the size of a 1.44MB floppy disk, which QEMU expects for floppy boot C) Compressing the image to reduce size D) Splitting the image into 512-byte sectors
Question 19 ⭐ Why does the MinOS scheduler use READY and BLOCKED states in addition to RUNNING?
A) To comply with POSIX process state requirements B) So the scheduler skips BLOCKED processes (waiting for I/O), preventing the scheduler from trying to run processes that cannot make progress C) BLOCKED state is used for processes waiting for memory allocation D) RUNNING state is only set when the process is actively executing a system call
Question 20
What is the QEMU -s flag used for in the debug build?
A) Enables SCSI disk emulation B) Starts a GDB server on port 1234, allowing GDB to connect and debug the running kernel C) Enables serial port output to stdout D) Suspends execution immediately after launch