Final Quiz

Forty questions covering the whole course.

Concept

Forty questions covering the whole course. Answer before reading the answer; revisit the referenced module for every miss.

Why It Matters

Testing yourself is the most effective way to find gaps.

Example

Stage 1 — How a Computer Works Q1. What is the 8-bit two's complement pattern of −1?

Answer: 1111 1111 (Module 2).

Q2. Why does 0.1 + 0.2 != 0.3 in C?

Answer: 0.1 and 0.2 have no exact binary representation; the rounded sum differs in the last bits.

Q3. Which gate is universal?

Answer: NAND (also NOR).

Q4. What does the carry flag indicate after an addition?

Answer: Unsigned overflow (carry out of the top bit).

Q5. Name two differences between x86-64 and RISC-V.

Answer: Variable vs fixed-length instructions; memory operands vs load/store architecture (also: 16 vs 32 general registers).

Q6. What does the program counter contain?

Answer: The address of the next instruction to fetch.

Q7. Which registers carry the first three integer arguments on x86-64 Linux?

Answer: rdi, rsi, rdx.

Q8. What does lea rax, [rdi+rdx] compute?

Answer: rdi + rdx into rax — address arithmetic without memory access.

Stage 2 — The Operating System Core Q9. How does a user program enter the kernel?

Answer: Through system calls, exceptions or interrupts.

Q10. What is stored in .bss?

Answer: Zero-initialized global and static variables (only the size is stored in the file).

Q11. What does execve do to the calling process?

Answer: Replaces its program image with a new program; same PID.

Q12. What is a zombie process and how is it removed?

Answer: A terminated process awaiting wait by its parent; reaping it removes it.

Q13. What makes a system call more expensive than a function call?

Answer: The privilege switch, register saving, argument checks, security mitigations and cache/TLB effects.

Q14. What is the vDSO?

Answer: A kernel-provided shared library mapped into every process so some calls (like clock_gettime) run in user mode.

Q15. Which signal does a NULL-pointer write produce?

Answer: SIGSEGV.

Q16. What do threads of a process NOT share?

Answer: Stacks and registers (each has its own).

Q17. Compute the average waiting time for FCFS with bursts 24, 3, 3 arriving at time 0 in that order.

Answer: (0 + 24 + 27) / 3 = 17.

Q18. And for SJF with the same bursts?

Answer: Order 3, 3, 24: (0 + 3 + 6) / 3 = 3.

Q19. What is priority inversion and its standard fix?

Answer: A high-priority task waits for a low-priority lock holder that is preempted by medium-priority work; fix with priority inheritance.

Q20. Why must pthread_cond_wait be called in a loop?

Answer: Spurious wake-ups and competing threads mean the condition may be false after waking.

Q21. Which deadlock condition does a global lock order break?

Answer: Circular wait.

Q22. What is the fastest IPC mechanism and what does it require?

Answer: Shared memory; explicit synchronization.

Stage 3 — Memory, Storage and I/O Q23. Name the three Cs of cache misses.

Answer: Compulsory, capacity, conflict.

Q24. Why is column-major traversal of a C array slow?

Answer: It jumps a whole row between accesses, defeating spatial locality and the prefetcher.

Q25. How many offset bits does a 64-byte cache line need?

Answer: 6.

Q26. What is a minor page fault?

Answer: A fault resolved without disk I/O (e.g. first touch of anonymous memory, copy-on-write).

Q27. What does the TLB cache?

Answer: Virtual-to-physical page translations.

Q28. Which page replacement algorithm can suffer Belady's anomaly?

Answer: FIFO.

Q29. What is internal fragmentation?

Answer: Unused space inside allocated blocks (e.g. rounding up to a power of two in a buddy allocator).

Q30. Where does a Unix file system store a file's name?

Answer: In the directory entry, not in the inode.

Q31. What happens to a file's data when it is deleted while a process has it open?

Answer: The name disappears; the inode and data remain until the last descriptor is closed.

Q32. Which disk scheduling algorithm can starve distant requests?

Answer: SSTF.

Q33. Why must MMIO register pointers be volatile?

Answer: So the compiler performs every access in order instead of caching or removing them.

Stage 4 — Performance and Advanced Architecture Q34. Which pipeline hazard needs a stall even with forwarding?

Answer: The load-use data hazard.

Q35. Why does sorting data speed up a loop containing if (x >= 128)?

Answer: The branch becomes predictable, eliminating mispredictions.

Q36. What does register renaming eliminate?

Answer: False dependencies (WAR and WAW).

Q37. In MESI, what happens to other copies when a core writes a Shared line?

Answer: They are invalidated.

Q38. What is false sharing and how do you fix it?

Answer: Independent data in one cache line causing coherence traffic; pad/align data to separate lines.

Q39. What is the difference between a VM and a container?

Answer: A VM runs its own kernel on virtual hardware; a container is an isolated group of processes sharing the host kernel (namespaces + cgroups).

Q40. A program's speedup is 1.93 on 2 threads. What parallel fraction does Amdahl's law imply?

Answer: About 0.96 (Module 29's challenge).

Expected Result

Aim for at least 32/40 (80%). Scores below that point to the modules to revisit.

Common Mistakes

Looking at answers first.

Skipping the numerical questions.

Best Practices

Redo the quiz a week later.

Explain each answer aloud as if in an interview.

Interview Relevance

The questions mirror common interview and exam questions.

Practice Questions

Write five more questions for your weakest stage.

For each missed question, rerun the corresponding module's example.

Explain Q17 and Q18 with Gantt charts.

Turn Q38 into a measurement on your own machine.

Quick Quiz

Q1. (True/False) You should memorize the latency numbers exactly.

Answer: False. Know the orders of magnitude and ratios.

Q2. (Multiple choice) A good final-quiz score to aim for is: A) 50% B) 65% C) 80% or more D) Only 100% Answer: C.

Q3. (Predict the output) FCFS average waiting time for bursts 24, 3, 3?

Answer: 17.

Q4. (Find the bug) "I missed Q24, so I'll memorize its answer."

Answer: Rerun Module 18's stride example and understand why — memorized answers don't transfer to new questions.

Coding Challenge

Verify Q17 and Q18 with a program that computes average waiting times for FCFS and SJF given bursts that all arrive at time 0.

#include <stdio.h>
#include <stdlib.h>

static int cmp(const void *a, const void *b) { return *(const int *)a - *(const int *)b; }

static double avg_wait(const int *bursts, int n)
{
    double t = 0, total = 0;
    for (int i = 0; i < n; i++) { total += t; t += bursts[i]; }
    return total / n;
}

int main(void)
{
    int fcfs[] = {24, 3, 3};
    int sjf[] = {24, 3, 3};
    qsort(sjf, 3, sizeof sjf[0], cmp);
    printf("FCFS average waiting time: %.1f\n", avg_wait(fcfs, 3));
    printf("SJF  average waiting time: %.1f\n", avg_wait(sjf, 3));
    return 0;
}