Module Quiz
Complete this quiz after finishing all concept and practice pages. Save your answers before opening separate quiz calibration.
Current Module Questions
Question 1: Process vs Program
State the difference between a program and a process in one sentence each.
Question 2: fork Return Values
A C program calls pid_t p = fork();. In which process is p == 0? What does a non-zero positive value mean, and what does a negative value mean?
Question 3: Syscall Sequence Tracing
Given this strace excerpt from a program invoked as ./prog input.txt:
openat(AT_FDCWD, "input.txt", O_RDONLY) = 3
read(3, "hello\nworld\n", 4096) = 12
write(1, "hello\nworld\n", 12) = 12
close(3) = 0
Write a C program whose source would produce exactly this sequence. What assumption did you have to make about the size of input.txt?
Question 4: Shell Redirection Mechanics
When a shell runs ./prog > out.txt, what exactly does the shell do to the child's fd table before exec?
Question 5: Race Condition Diagnosis from Output
Two threads each increment a shared long counter one million times. Final value observed across 10 runs: 1384122, 1602910, 1441098, 1712045, 1500388, .... None reaches 2000000. Explain the specific race.
Question 6: mmap vs read
A program repeatedly accesses random 8-byte records in a 10 GB file. Would you reach for mmap or read/lseek? Defend your choice.
Question 7: Producer-Consumer Correctness
In the canonical producer-consumer, why is while (empty) cond_wait(¬_empty, &m); used instead of if (empty) cond_wait(¬_empty, &m);? Give two independent reasons.
Question 8: FD Table Through pipe + fork + dup2
Before: parent has pipe returning p[0]=3, p[1]=4. Parent forks. Each child wants to be one side of A | B. Write out the fd table of each child right before exec, assuming A is the writer.
Question 9: Signal Safety
Why is calling printf from inside a signal handler dangerous, and what should you do instead in a long-running program?
Question 10: Debugging Tool Selection
A server suddenly spikes to 100% CPU and responses time out. Pick the first diagnostic tool to reach for and justify the choice. Then pick the first tool if the same server is instead hung at 0% CPU and justify that choice.
Interleaved Review Questions (from previous modules)
Question 11: (from S4M1, C Fundamentals)
Why does the C declaration char *p = "hello"; produce a string you cannot modify, while char p[] = "hello"; does?
Question 12: (from S4M2, Memory and Pointers)
In a C program, where does malloc-returned memory physically come from, assuming a glibc userspace?
Question 13: (from S4M3, Computer Organization)
Explain why accessing a pointer in a tight inner loop can be dramatically faster the second time than the first.
Question 14: (from S3M1, Software Design)
A programmer wraps every syscall in a "safety" class with 20 methods. Discuss in terms of cohesion and SRP.
Question 15: (from S2M2, Algorithms)
What is the time complexity of a correct wc -c implementation over a file of size N bytes, in terms of syscalls and in terms of user-mode work?
Progression boundary
Quiz performance calibrates retrieval and reasoning. It does not replace runnable work, changed-case transfer, the module assessment or required semester evidence. Consult practice calibration for the additional independent cases.