IIT Patna — M.Tech (AI & DS) · ECS 5102 · Quiz 2 (22–26 Nov 2026)
Compiled 29 Nov 2026 · 20 questions · answer check: 20 / 20 correct ✅
Every answer below was verified against the course lecture notes and the recorded class transcripts — not against general knowledge alone. Sources are quoted per question.
How this set was validated
| Source | Path | Used for |
|---|---|---|
| Session #1 — Computer System Foundations | ../Lecture Notes/FCS - Session #1 - Computer System Foundations.md |
Q3, Q5 |
| Session #2 — ISA | ../Lecture Notes/FCS - Session #2 - ISA.md |
Q1, Q9, Q14, Q19 |
| Session #3 — CPU & Instruction Cycle | ../Lecture Notes/FCS - Session #3 - CPU Instruction Cycle.md |
Q12 |
| Session #4 — Process & System Calls | ../Lecture Notes/FCS - Session #4 - Process System Calls.md |
Q4, Q5 (context-switch overhead) |
| Memory Hierarchy and Virtual Memory | ../Lecture Notes/FCS Session - Memory Hierarchy and Virtual Memory.md |
Q2, Q7, Q8, Q13 |
| RISC/CISC and I/O | ../Lecture Notes/FCS_ Session_RISC_CISC_and_IO.md |
Q9, Q11, Q17, Q19 |
| Synchronization and IPC | ../Lecture Notes/FCS_Session_Synchronization_and_IPC.md |
Q6, Q10, Q16, Q18 |
| Threads and CPU Scheduling | ../Lecture Notes/FCS_Session_Threads_and_CPU_Scheduling.md |
Q4, Q15, Q20 |
| Class transcripts (11, 17, 25, 31 Oct · 22 Nov 2026) | ../../../../transcribe/output/5102-foundations-of-comp-sys/ |
spoken wording that confirms each answer |
Related files in this folder: FCS Quiz1 25 questions_2026-10-28_22-07.md ·
FCS assessment 20 questions_2026-11-14_14-39.md ·
quiz-1-question-bank.md
Quick answer key
| Q | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Answer | A | False | False | D | B | D | A | A | A | A |
| Q | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|
| Answer | A | B | B | False | False | A | False | C | C | D |
Question 1 — Immediate addressing
A processor instruction uses an immediate addressing mode to add a constant value to a register. The engineer claims that the constant must first be fetched from a separate memory location because all instruction operands are stored in memory. Which statement is correct?
- A. Immediate addressing means the operand value is encoded as part of the instruction.
- B. Immediate addressing means the operand is always stored in the program counter.
- C. Immediate addressing requires the operand to be read from an external I/O device.
- D. Immediate addressing is supported only by CISC processors.
Correct answer: A. Immediate addressing means the operand value is encoded as part of the instruction.
Why: the constant sits in a field inside the instruction itself. In ADD R1, #5, the value 5
is part of the instruction's encoding. Once the instruction has been fetched and decoded, the
constant is already in the processor, so no separate data-memory access is needed.
Lecture: "Immediate Addressing: Operand is a constant embedded directly in the instruction (e.g.,
ADD R1, #10)." — Session #2 ISA, §3The same slides give the field its bit budget: "Function / Immediate Bits (Bits 10–0): Additional function codes or small immediate constants." — §4
The engineer's claim is wrong because not all operands live in separate memory locations. The instruction is still fetched from memory or cache, but the immediate value arrives with it. The immediate field has limited bits, so large constants may need multiple instructions or a load from memory.
Why the other options are wrong
- B — The program counter holds the next instruction address. It is a base in PC-relative addressing, a different mode.
- C — The value comes from the instruction, not an I/O device.
- D — RISC architectures such as MIPS, ARM and RISC-V also support immediate addressing; the course compares x86-64, ARM64 and RISC-V precisely because all three have it.
Source: Session #2 ISA §3–§4; RISC/CISC & I/O slides 8–12.
Question 2 — Cache hierarchy
A cloud application experiences an L1 cache miss while processing a frequently accessed data structure. The performance engineer immediately concludes that the requested data must be fetched from DRAM and that the application has incurred the full main-memory access penalty. True or False?
Correct answer: False
Why: an L1 miss doesn't mean the data must come from DRAM. The request is checked at L2, then L3 (or supplied by another core's cache through the coherence protocol). DRAM is accessed only if the data isn't available anywhere in the cache hierarchy.
Transcript, 31 Oct 2026: "if L1 misses, but L2 hits, did we need to fetch the data from RAM? No. If you are able to hit at L2, definitely the data is not going to be there in L3 or RAM… the moment you hit, the process stops."
Lecture: "Miss: requested block is absent; a lower level must supply it." — Memory Hierarchy, slide 8. A "lower level" can be L2, not necessarily DRAM.
Rough, architecture-dependent latencies: L1 ≈ 4 cycles, L2 ≈ 10–15, L3 ≈ 30–70, DRAM often 200+.
Frequently accessed data may well still be in L2 or L3. Check per-level miss rates with hardware
counters (e.g. perf or Intel VTune); cloud VMs may restrict access to them.
Source: Memory Hierarchy notes, slides 4, 8, 14; transcript 31 Oct 2026.
Question 3 — CPU-bound and I/O-bound work
An enterprise application experiences a sudden increase in processing time after its workload changes from simple arithmetic operations to frequent file and network operations. The development team concludes that the CPU must be defective because the processor is responsible for executing all application instructions. True or False?
Correct answer: False
Why: the workload has changed from CPU-bound to largely I/O-bound, so execution time depends heavily on components much slower than the processor. Likely contributors:
- Storage latency: microseconds to milliseconds, versus nanoseconds or less for arithmetic.
- Network delays: latency, bandwidth limits, congestion and slow remote services.
- Software overhead: system calls, context switches, interrupts and data copying.
- Application design: blocking I/O, many small reads or writes, lock contention.
Transcript, 31 Oct 2026 (the OTP example): "if a program performs very little arithmetic, but repeatedly fetches data, OTP is a great example… this OTP has to travel through network…" — the screen responds instantly while the actual delay is network and gateway work, not CPU work.
Measure CPU utilisation, I/O wait, disk latency and network performance (e.g. vmstat, iostat,
strace, Wireshark). Suspect hardware only with specific evidence, such as machine-check errors or
failed diagnostics.
Source: Session #1 notes (performance = instruction count × CPI × clock, §5); transcript 31 Oct 2026.
Question 4 — Round Robin time quantum
An online transaction service uses Round Robin scheduling. The operations team reduces the time quantum significantly to improve responsiveness. After deployment, they observe a noticeable increase in context-switching activity. Which explanation is most appropriate?
- A. A smaller time quantum converts all application threads into kernel threads.
- B. Round Robin scheduling guarantees the lowest possible turnaround time.
- C. A smaller time quantum eliminates context switching.
- D. A smaller time quantum can increase the frequency of scheduling and context-switching activity, adding overhead.
Correct answer: D.
Why: each thread runs for at most one quantum before being preempted. A smaller quantum means threads needing more CPU time are preempted more often.
Lecture: "Small quantum: More frequent preemption; greater scheduling overhead." — Threads & CPU Scheduling, slide 19
Transcript, 11 Oct 2026: "if it is too small, the scheduler may spend a longer proportion of its time switching between the task. The switching between the task is also going to come with a cost."
Session #4 notes, §4: "excessively small time quantums in Round Robin cause degraded system throughput due to frequent switching."
- Direct overhead: saving and restoring registers and running the scheduler.
- Indirect overhead: disturbed cache and TLB contents (slide 11: "cache locality and address-translation effects may reduce efficiency").
A smaller quantum can improve response time, but if too small it reduces throughput. A very large quantum makes Round Robin behave like FCFS.
Why the other options are wrong
- A — The quantum has no effect on thread type.
- B — No such guarantee. SJF/SRTF minimise average waiting/turnaround under idealized assumptions; the lecture's own table gives SJF the lowest turnaround (7.75 ms vs RR 11.25 ms).
- C — A smaller quantum generally increases switching.
Source: Threads & CPU Scheduling slides 11, 19; Session #4 §4; transcript 11 Oct 2026.
Question 5 — Program loading
A developer runs a program from an SSD. The application executable is loaded into main memory before the CPU begins executing its instructions. Which statement best explains this behaviour?
- A. The application must be copied into the I/O controller before it can execute.
- B. The executable is stored in secondary storage, while the running program's instructions and data are made available in main memory for execution.
- C. The SSD replaces the CPU's instruction decoder during program execution.
- D. The CPU directly executes the application from the SSD in the same way it executes instructions from registers.
Correct answer: B.
Why: the SSD provides non-volatile storage. At launch, the OS creates a process, sets up its virtual address space and maps the needed code and data into RAM. The CPU fetches instructions from RAM through the cache hierarchy.
Lecture, Session #1 §3: RAM = "Active workspace for running programs & data", "Directly accessed by CPU memory instructions"; Storage = "Long-term non-volatile data retention" for "executables and files", "Indirectly accessed via I/O storage controllers & DMA".
Transcript, 04 Oct 2026: "it's not that the entire Word document is loaded into the memory… that's where this memory swap works… paging means it is swapping between the hard disk and the memory."
The whole executable need not be loaded first. With demand paging, pages are loaded when first accessed; a reference to a non-resident page causes a page fault.
Lecture: "Demand paging loads a page when first accessed rather than loading the whole address space upfront." — Memory Hierarchy, slide 22
Why the other options are wrong
- A — The I/O controller manages transfers; programs do not execute from it.
- C — The SSD has no role in instruction decoding.
- D — The CPU normally cannot execute directly from a block-based SSD; the ISA expects a memory address space, which is why the OS maps code/data into RAM.
Source: Session #1 §3; Memory Hierarchy slide 22; transcript 04 Oct 2026.
Question 6 — Producer-consumer coordination
A data-processing service uses a bounded buffer between producer threads and consumer threads. A consumer attempts to retrieve an item when the buffer is empty. Which mechanism best represents the required coordination?
- A. The consumer should terminate because an empty buffer indicates a process failure.
- B. The producer should acquire the consumer's CPU register set.
- C. The consumer should continue removing elements until the buffer becomes non-empty.
- D. The consumer should wait until an available-item signal indicates that data can be consumed.
Correct answer: D.
Why: the consumer should block until a producer adds an item and signals it. A common solution uses two counting semaphores and a mutex:
| Primitive | Initial value | Purpose |
|---|---|---|
full |
0 | Counts available items; consumers wait when zero |
empty |
N (buffer size) | Counts free slots; producers wait when zero |
mutex |
1 | Protects the shared buffer |
Producer: wait(empty); wait(mutex); insert; signal(mutex); signal(full)
Consumer: wait(full); wait(mutex); remove; signal(mutex); signal(empty)
Lecture, Synchronization & IPC slide 16:
empty = N"Counts free slots. Producer acquires before insert.";full = 0"Counts available items. Consumer acquires before remove.";mutex"Protects the queue while adding or removing." — the exact table above.Slide 18: "
full.acquire()— reserve an available item. Why acquire first? Prevents removal from an empty buffer."Session exit assessment, item 3: "Consumer finds buffer empty → Wait for available-item signal." — the answer is given verbatim in the slides.
Order matters: a consumer that locks the mutex before waiting on full with an empty buffer blocks
producers, causing deadlock. Condition variables also work, rechecking in a while loop.
Why the other options are wrong
- A — An empty buffer is a normal temporary state.
- B — Registers are unrelated to this coordination.
- C — This causes underflow and cannot fill the buffer.
Source: Synchronization & IPC slides 15–20, 28; exit assessment item 3.
Question 7 — L2 cache hits
An application experiences frequent L1 cache misses. During performance analysis, engineers discover that many of the requested cache lines are present in the L2 cache. Which conclusion is correct?
- A. The processor can obtain the requested data from L2 without necessarily accessing DRAM.
- B. Every L1 cache miss necessarily causes a DRAM access.
- C. A cache miss means that the requested data has been permanently lost.
- D. L2 cache is used only for instructions and cannot hold application data.
Correct answer: A.
Why: on an L1 miss that hits in L2, the line is supplied from L2, usually also being copied into L1. The penalty is higher than an L1 hit but far lower than DRAM access.
Transcript, 31 Oct 2026: "If you are able to hit at L2, definitely the data is not going to be there in L3 or RAM… the moment you hit, the process stops."
Transcript, 13 Sep 2026: "when it comes to the instructional register, it enters L2 first… L2 will split instruction… instruction is in L1, data is in L1d" — the cache hierarchy is a chain, not a single jump to RAM.
L1 misses can be reduced by better data locality: compact structures, sequential access or loop tiling.
Why the other options are wrong
- B — L2, L3 or another cache may satisfy the miss.
- C — A miss only means the data is not at that level.
- D — L2 is typically unified, holding instructions and data.
Source: Memory Hierarchy slides 4, 8; transcripts 31 Oct & 13 Sep 2026.
Question 8 — Write-back caches
A processor uses a write-back cache policy. An application modifies the same cached data line several times. The systems engineer expects every write to be immediately propagated to the next memory level. Which statement correctly describes write-back behaviour?
- A. The cache line is updated and marked dirty; propagation to the next level is deferred until a later write-back event.
- B. Write-back means that data is never written to lower memory levels.
- C. Every write is immediately propagated to the next memory level.
- D. The processor discards the modified cache line after every write.
Correct answer: A.
Why: a write hit updates only that cache level and sets the dirty bit. The line is written down later, typically on eviction, an explicit flush or clean, or when the coherence protocol requires it. Several writes can combine into a single write-back, reducing traffic. Lower levels may be temporarily stale, so coherence is needed.
Lecture, Memory Hierarchy slide 13: "Write-back: update cache and mark line dirty; write to lower memory on eviction or flush." (Contrast: "Write-through: update cache and lower memory on each write.")
Transcript, 22 Nov 2026: "write back actually marks the cache line dirty… until eviction or even flush", and "write-back may reduce lower-level write when multiple writes to a line are combined."
Transcript, 22 Nov 2026 (demo output): "write back… will not write it back to the memory. It will just mark the cache line as dirty."
Why the other options are wrong
- B — Writes are delayed, not prevented.
- C — This describes write-through.
- D — Discarding a dirty line would normally lose data.
Source: Memory Hierarchy slide 13; transcripts 22 Nov 2026.
Question 9 — Instruction formats
A software team is analysing an instruction format that contains an opcode, register identifiers and an immediate field. A junior engineer assumes that every instruction in every ISA must have exactly the same number of bits. Which statement is most accurate?
- A. Instruction formats and encoding rules are defined by the ISA, and instruction length can vary between architectures.
- B. All ISAs use fixed-length instructions.
- C. Instruction length is determined only by the CPU clock frequency.
- D. The operating system chooses the binary encoding of every instruction at runtime.
Correct answer: A.
Why: the ISA specifies how instructions are encoded. Length can differ between ISAs and sometimes within one:
| ISA | Instruction length |
|---|---|
| MIPS32 (base) | Fixed 32 bits |
| AArch64 | Fixed 32 bits |
| RISC-V | 32-bit base, optional 16-bit compressed |
| ARM Thumb-2 | Mix of 16 and 32 bits |
| x86/x86-64 | Variable, 1 to 15 bytes |
Lecture, RISC/CISC & I/O, comparison table: x86-64 "Variable length"; ARM64 "primarily fixed 32-bit encodings"; RISC-V "32-bit base; compressed 16-bit extension".
Session #2 ISA §4: a fixed 32-bit instruction "must balance its bit budget" — opcode, registers and immediate all compete for the same bits.
Fixed length simplifies fetch and decode; variable length can improve code density at the cost of decoding complexity.
Why the other options are wrong
- B — x86 and others are variable-length.
- C — Clock frequency affects timing, not encoding.
- D — Encoding is defined by the ISA and normally produced by compilers, assemblers or JITs.
Source: Session #2 §4; RISC/CISC & I/O slides 8–12.
Question 10 — Race conditions
An e-commerce application has one item remaining in inventory. Two request-handling threads execute almost simultaneously. Both read the inventory value as 1, both validate that stock is available, and both confirm an order. Which change most directly prevents this lost-update/race-condition scenario within a shared process?
- A. Protect the complete read-validate-update operation as one critical section.
- B. Increase the CPU clock frequency.
- C. Increase the number of application threads.
- D. Place only the final inventory decrement inside a mutex, leaving the read and validation outside it.
Correct answer: A.
Why: this is a check-then-act race. The read, validation and update must execute atomically:
lock(inventory_mutex)
if inventory > 0:
inventory = inventory - 1
order_accepted = true
else:
order_accepted = false
unlock(inventory_mutex)
The second thread then sees 0 and rejects the order. A mutex like this works within one process; multiple processes or servers need shared coordination, such as database transactions or conditional updates (see Q16).
Lecture, Synchronization & IPC slide 7: "Lock the complete logical operation — not just the final assignment. A lock works only if every relevant access follows the same synchronization protocol."
Slide 11 (Lab 1 repair): "One thread at a time executes the full read-modify-write sequence."
Slide 6: the counter example — "The update is not one indivisible operation: read → compute → write", observed 101 instead of 102.
Why the other options are wrong
- B — Changes timing but not the race; on multiple cores it can even widen the window.
- C — Can make the race more likely.
- D — Both could pass validation before locking, leaving inventory at −1.
Source: Synchronization & IPC slides 4, 6–7, 11.
Question 11 — Polling versus interrupts
An industrial monitoring system receives sensor readings at irregular intervals. The engineering team is considering whether to use polling or interrupts to detect incoming events. Which statement is the best basis for selecting the mechanism?
- A. The decision should consider event frequency, response-time requirements and the overhead of repeatedly checking devices or handling interrupts.
- B. Polling is always superior because it avoids all CPU overhead.
- C. Interrupts are always superior because they eliminate all processing delay.
- D. Polling and interrupts are identical mechanisms with different names.
Correct answer: A.
Why:
| Aspect | Polling | Interrupts |
|---|---|---|
| Detection | CPU checks repeatedly | Device signals CPU |
| Overhead | Wasted checks | Context saving and handler per event |
| Response time | Depends on polling interval | Usually prompt; affected by latency, priority, masking |
| Typically suits | Frequent or predictable events | Infrequent or irregular events |
Irregular readings make interrupts a strong candidate, but verify response deadlines. At very high event rates, polling or a hybrid may be better.
Lecture, RISC/CISC & I/O slide 17: "Polling: trade-offs depend on event rate and timing… Costs / risks: wasted CPU cycles, detection delay between checks, and contention under heavy load."
Transcript, 25 Oct 2026: "frequent polling consumes our processor time. While slow polling may delay direct detection… we need to have the right interval, depends on the event rate."
Why the other options are wrong
- B — Polling consumes CPU time.
- C — Interrupts still have latency and overhead (slide 16: "An interrupt does not imply that an application runs immediately or that latency is bounded.").
- D — One is CPU-initiated, the other event-driven.
Source: RISC/CISC & I/O slides 15–17, 26; transcript 25 Oct 2026.
Question 12 — Program counter
During debugging, an engineer observes that a program repeatedly executes an instruction at the wrong address after a conditional branch. The team suspects that the instruction sequence is being fetched incorrectly. Which CPU register is most directly associated with holding the address of the next instruction to be fetched?
- A. Memory Data Register (MDR)
- B. Program Counter (PC)
- C. Instruction Register (IR)
- D. Status/Flags Register
Correct answer: B. Program Counter (PC)
Why: the PC holds the next instruction's address. It normally advances sequentially, but a taken
branch loads the target. In x86-64 it is the instruction pointer (RIP). Also check the condition
flags, branch target calculation and preceding comparison.
Lecture, Session #3 §2: "Program Counter (PC): Holds the memory address of the next instruction to be fetched and executed. Automatically incremented after fetch."
Session #3 §3 fetch phase: "
PCholds address0x1000. Memory places instruction binary intoMDR, which loadsIR.PCis incremented to0x1004."
Why the other options are wrong
- A — MDR holds data or instructions in transit.
- C — IR holds the current instruction.
- D — Flags can decide a branch but do not hold the fetch address.
Source: Session #3 §2–§3.
Question 13 — Spatial locality
A data analytics application processes a large two-dimensional array stored in C row-major order. The developer can choose either row-wise or column-wise traversal. The application currently traverses the array column by column and experiences poor cache performance. Which change is most likely to improve spatial locality?
- A. Increase the number of conditional branches in the inner loop.
- B. Traverse the array row by row so that adjacent elements in memory are accessed consecutively.
- C. Traverse the array in a random order to avoid repeated cache lines.
- D. Replace all array accesses with accesses to secondary storage.
Correct answer: B.
Why: elements of a row are contiguous, so put the row index in the outer loop:
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
sum += a[i][j];
}
}
A 64-byte line holds 16 four-byte integers, so aligned sequential traversal incurs about one miss per
16 elements, before prefetching. Column-wise access jumps COLS * sizeof(element) bytes, and lines
may be evicted before reuse.
Lecture, Memory Hierarchy slide 7: "values[0], values[1], values[2]… Adjacent elements often occupy adjacent byte addresses. One cache-line fill can supply several future loads."
Transcript, 22 Nov 2026: "a row-wise traversal of Python, numpy array, is usually more cache friendly than jumping randomly access memory."
Why the other options are wrong
- A — Does not improve the access pattern.
- C — Generally destroys spatial locality.
- D — Secondary storage is far slower.
Source: Memory Hierarchy slides 5, 7; transcript 22 Nov 2026.
Question 14 — ISA and microarchitecture
A software vendor wants to run the same application binary on two processors that implement the same ISA but use different internal microarchitectures. The vendor assumes that the processors must have identical pipeline depths, cache organizations and execution units because their ISA is identical. True or False?
Correct answer: False
Why:
| Level | Defines | Examples |
|---|---|---|
| ISA | What software sees | Instructions, registers, addressing modes, encoding, memory and exception behaviour |
| Microarchitecture | How the ISA is implemented | Pipeline depth, caches, execution units, branch prediction, out-of-order execution |
Many Intel and AMD processors implement x86-64 differently: the same binary can run on both with different performance and power. Compatibility also requires the needed ISA extensions (e.g. AVX-512) and a compatible OS, ABI and libraries.
Lecture, Session #2 §5: "Two processors (e.g., Intel Core i7 and AMD Ryzen) can share the exact same ISA (x86-64) and run the exact same binary, while possessing completely different internal microarchitectures."
RISC/CISC & I/O slide 7: "Both can implement the same ISA while differing substantially in performance, power, cost and area."
Transcript, 25 Oct 2026 opening question: "If two processors run the same program, must their internal designs be identical?" → "software sees: instructions, registers, exceptions, memory model" / "hardware varies: pipelines, caches, exec units, prediction."
Source: Session #2 §5; RISC/CISC & I/O slides 6–7; transcript 25 Oct 2026.
Question 15 — FCFS versus Round Robin
A database service has multiple runnable threads competing for CPU time. The system administrator changes the scheduling policy from First-Come, First-Served (FCFS) to Round Robin with a fixed time quantum. The administrator claims that Round Robin will always reduce the average turnaround time of every process. True or False?
Correct answer: False
Why: Round Robin mainly improves response time. Example: P1, P2, P3 arrive together in that order, each needing 10 units; quantum 1, no switching overhead.
| Process | FCFS completion | Round Robin completion |
|---|---|---|
| P1 | 10 | 28 |
| P2 | 20 | 29 |
| P3 | 30 | 30 |
| Average turnaround | 20 | 29 |
Round Robin can help when a long job precedes short ones (the convoy effect). Results depend on burst times, arrival order, quantum and switching overhead.
Lecture, Threads & CPU Scheduling: "Small quantum: more frequent preemption… Large quantum: for many workloads, behaviour approaches FCFS." Slide 21: FCFS avg turnaround 11.50 ms vs RR (q=2) 11.25 ms — RR is only marginally better on that workload, and P1's own turnaround goes from 7 ms (FCFS) to 16 ms (RR).
Transcript, 11 Oct 2026: "round robin also has another disadvantage, it has the longest completion period, turnaround time. It goes with the quantum… we just can't decide with a simple [rule]."
Slide 21 conclusion: "SJF has the lowest average waiting/turnaround; RR has the lowest average response."
Source: Threads & CPU Scheduling slides 15, 19, 21; transcript 11 Oct 2026.
Question 16 — Distributed concurrency
A company runs several application-server instances behind a load balancer. Each instance processes orders and accesses the same inventory database. The team proposes using a local mutex in each application-server process to prevent two instances from reserving the same final item. Which design decision is most appropriate?
- A. Use a shared-store concurrency mechanism, such as an atomic conditional database update or suitable transaction control, to enforce the inventory invariant across instances.
- B. A local mutex in each process is sufficient because all processes share the same memory automatically.
- C. Increase the number of application-server instances so that requests are processed faster.
- D. Remove all synchronization because the database will automatically prevent every race condition.
Correct answer: A.
Why: a local mutex coordinates only its own process, so the rule must be enforced in the shared database:
UPDATE inventory
SET stock = stock - 1
WHERE product_id = ? AND stock > 0;
Confirm only if one row was affected, and commit the decrement and order record in the same
transaction. Alternatives: SELECT ... FOR UPDATE, serializable isolation with retries, or
optimistic version columns.
Lecture, Synchronization & IPC slide 27: the exact
UPDATE … WHERE quantity > 0statement; "1 row: reservation succeeded. 0 rows: no eligible stock update."; "Multiple app instances need coordination enforced by a shared data store or distributed mechanism."; "A mutex alone does not solve distributed transactions or partial failure."Slide 26 (application exercise) asks the scaling question directly: "Will a local mutex work across servers?"
Session exit assessment, item 4: "Multiple app servers share inventory → Database/shared concurrency control."
Why the other options are wrong
- B — Separate processes do not automatically share memory (Threads & Scheduling slide 5: "ordinary private memory is not automatically shared across processes").
- C — More instances increase concurrency.
- D — Protection depends on queries, constraints, locks and isolation level.
Source: Synchronization & IPC slides 26–27, exit assessment item 4.
Question 17 — Interrupt trade-offs
A real-time monitoring system uses polling to check whether a sensor has produced new data. The engineering team changes to an interrupt-driven design, expecting the CPU to be notified when the sensor requires attention rather than repeatedly checking its status. The team concludes that polling is always inefficient and interrupts are always the superior solution for every device. True or False?
Correct answer: False
Why:
| Situation | Often better | Reason |
|---|---|---|
| Infrequent, irregular events | Interrupts | Avoids wasted checks |
| Very high event rates | Polling or hybrid | Interrupt overhead can overwhelm the CPU |
| Very short, predictable waits | Polling | Can respond faster |
| Simple fixed-rate sampling | Periodic polling | Simple, predictable timing |
Interrupts cost context saving, handler execution, latency and priority management. An interrupt flood can cause livelock. Linux NAPI uses an interrupt first, then polls under heavy traffic. Choose by event rate, deadlines, hardware and power needs.
Lecture, RISC/CISC & I/O slide 26: "Do not accept 'always use interrupts' or 'DMA replaces interrupts.' Require explicit assumptions."
Slide 17: polling "can be useful when the check interval is known, the device is fast, or the system can process work in batches."
Transcript, 25 Oct 2026: "polling is controllable… the frequency. Interrupt will happen only at the completion of the event" — and the S3/file-arrival example where both are used together.
Source: RISC/CISC & I/O slides 16–17, 26; transcript 25 Oct 2026.
Question 18 — Condition variables
A producer-consumer application uses a condition variable. A consumer wakes after waiting on the condition variable. The developer immediately removes an item from the buffer without checking whether the buffer is still non-empty. Why is this implementation unsafe?
- A. A condition variable can only be used between different computers.
- B. A condition variable automatically creates a new process whenever a thread wakes.
- C. A wake-up does not itself guarantee that the condition predicate is true when the thread resumes; the consumer must re-check the predicate, typically in a loop.
- D. A condition variable permanently reserves the buffer for the thread that wakes.
Correct answer: C.
Why: the buffer may be empty because another consumer got there first, a spurious wake-up occurred, or broadcast/shared signalling woke the thread.
pthread_mutex_lock(&mutex);
while (count == 0) {
/* re-check after every wake-up */
pthread_cond_wait(¬_empty, &mutex);
}
item = remove_item();
pthread_cond_signal(¬_full);
pthread_mutex_unlock(&mutex);
pthread_cond_wait atomically releases the mutex and blocks, then reacquires it before returning.
Lecture, Synchronization & IPC slide 22: "
while not ready: condition.wait()— Why while? Wake-up does not prove the condition is true. Why lock? Predicate check and update must be coordinated."Slide 21: "Condition variable: wait until a condition may have changed; waiting releases the lock. Predicate loop: re-check shared state after waking and reacquiring the lock."
Session exit assessment, item 5: "Thread wakes from
Condition.wait()→ Re-check predicate in a while loop."
Why the other options are wrong
- A — Commonly used between threads in one process.
- B — Waking creates no process.
- D — It reserves nothing.
Source: Synchronization & IPC slides 21–22, exit assessment item 5.
Question 19 — ISA as a contract
A compiler generates two different assembly sequences for the same high-level operation on two processors that implement the same ISA. One processor has a deeper pipeline and a larger cache, while the other has a simpler execution design. Which statement best explains how both processors can execute software designed for the same ISA?
- A. The processor with the larger cache automatically implements a different ISA.
- B. They must have identical internal CPU designs.
- C. The ISA defines the software-visible behaviour, while each processor may use a different microarchitecture to implement it.
- D. The compiler must generate a different instruction set for each microarchitecture.
Correct answer: C.
Why: the ISA is a contract between software and hardware. Pipeline depth and cache size are microarchitectural choices affecting performance, power and area, not the defined results of correct programs.
Compilers may tune sequences per processor (scheduling, unrolling). Code using an optional extension will not run correctly where it is unsupported.
Lecture, RISC/CISC & I/O slide 6: the ISA covers "instruction set… architectural registers… instruction encodings and rules for decoding… memory access rules… exceptions"; "the ISA is a contract/API for machine code; the microarchitecture is one way to implement it."
Slide 7: "Both can implement the same ISA while differing substantially in performance, power, cost and area."
Session #2 §1: "The ISA is the programmer-visible contract and interface specification between software and hardware."
Why the other options are wrong
- A — Cache size does not change the ISA.
- B — Internal designs can differ greatly.
- D — Tuning does not require a different instruction set.
Source: Session #2 §1, §5; RISC/CISC & I/O slides 6–7.
Question 20 — Thread-pool sizing
A backend service has several worker threads. During monitoring, engineers observe that the CPU is not fully utilised, while many threads spend substantial time waiting for database responses. The team proposes increasing the number of worker threads to improve throughput. Which approach is most appropriate before making the change?
- A. Disable context switching so that each thread can run continuously.
- B. Increase the thread count without further investigation because more threads always increase throughput.
- C. Replace Round Robin with FCFS because FCFS eliminates I/O wait time.
- D. Measure the workload and identify whether the bottleneck is CPU, database capacity, connection limits or I/O waiting before changing the thread count.
Correct answer: D.
Why: the service appears I/O-bound; more threads help only if downstream resources can handle them.
| What to measure | What it can reveal |
|---|---|
| Database latency and load | Slow queries, lock contention, saturation |
| Connection pool usage and wait | Threads queuing for connections |
| Network latency | Service-to-database delays |
| Thread states and request queue | Whether requests wait for a free thread |
| Memory and context-switch rate | Cost of more threads |
If more threads would help, increase gradually under load testing, watching throughput and tail latency.
Lecture, Threads & CPU Scheduling slide 26: "Diagnose before changing the scheduler" — measure "CPU utilisation, runnable queue length, application queue depth, latency percentiles, database wait time"; trade-offs: "Too few workers: queueing. Too many: contention."
Transcript, 17 Oct 2026: the closing questions include "What could happen if the application creates too many worker threads? What measurements would you collect before recommending a scheduling-related change?"
Why the other options are wrong
- A — Switching lets others run while some wait.
- B — Extra threads add contention and overhead.
- C — FCFS does not eliminate I/O wait; it only changes queue order.
Source: Threads & CPU Scheduling slides 25–26; transcript 17 Oct 2026.
Notes and caveats
Correct, but not from the slides (fine as supporting detail, don't cite as lecture facts):
- Q2 / Q7 — the cycle figures (L1 ≈ 4, L2 ≈ 10–15, L3 ≈ 30–70, DRAM ≈ 200+) are textbook
numbers. The slides deliberately say "exact levels vary by processor" and give no counts.
perf/ VTune are also not mentioned in class. - Q13 — "64-byte line holds 16 four-byte integers" is an added example; the slide only shows a generic cache line.
- Q9 — the MIPS32 and ARM Thumb-2 rows are accurate but not in the course table.
- Q6 — the lecture uses
acquire()/release(); this quiz useswait()/signal()(Dijkstra naming). Same semaphore pair, both accepted. - Q12 —
RIPfor x86-64 is correct but not stated in the notes.
Two wording improvements (not errors):
- Q9 option A — say length can vary "between architectures and sometimes within one". x86-64's 1–15 byte range is the case that actually breaks the junior engineer's assumption.
- Q15 — phrase it as "RR does not guarantee lower turnaround", not "RR increases turnaround". The lecture's own workload gives RR 11.25 ms vs FCFS 11.50 ms, so RR is marginally better there; the word "always" is what makes the statement false.
Exam pattern to remember: Q4, Q15 and Q20 are the same idea in three costumes — measure first, and a smaller quantum / more threads is not automatically better. Q2 and Q7 are one idea (miss ≠ DRAM). Q14 and Q19 are one idea (ISA = contract, microarchitecture = implementation).
Validated 29 Nov 2026 against the lecture notes and the transcripts of 11, 17, 25, 31 Oct and 22 Nov 2026. All 20 answers correct as submitted.