🎓 BookMCQ
← Back to 2. Operating System Structure

📝 Operating system debugging techniques (30 MCQs)

Diagnosing Kernel and Application Failures

Operating system debugging techniques identify, analyse, and correct faults in kernel components, device drivers, system services, and applications. Debugging uses diagnostic information such as error messages, execution traces, memory dumps, logs, and performance measurements. It supports the reliability of process management, memory handling, file systems, and device operations by revealing where actual behaviour differs from expected execution.

Why Operating System Failures Require Systematic Investigation

Operating systems execute concurrent processes and interact with hardware, making failures difficult to reproduce and trace. A visible application error may originate from a driver, memory corruption, resource exhaustion, or an unrelated subsystem. Systematic debugging collects evidence about execution state and recent events, helping developers distinguish the original fault from its secondary effects without introducing additional system instability.

Logs, Tracing, Breakpoints, and Memory Dumps

Developers inspect system logs to identify reported errors, use tracing to follow system calls and kernel events, and apply breakpoints to examine execution at selected locations. Crash dumps preserve relevant memory and processor state after serious failures. Profiling tools measure performance, while assertions and debug symbols help associate execution behaviour with source code and internal structures.

Investigating a Process That Hangs During File Access

Suppose an application becomes unresponsive while reading a file. A developer checks its process state and system-call trace, discovering that read() remains blocked. System logs may reveal storage errors, while device and kernel diagnostics help identify the responsible subsystem. This evidence separates an ordinary I/O wait from a malfunctioning device or driver.

Debugging Accuracy, System Overhead, and Diagnostic Limits

Logging and tracing improve fault identification and help locate performance bottlenecks in production and development systems. However, excessive diagnostic activity consumes CPU time, storage, and memory, potentially changing the behaviour being investigated. Kernel debugging may also require privileged access and specialised crash information. Some timing-sensitive or intermittent faults remain difficult to reproduce even with extensive instrumentation.

Misconceptions About Logs, Traces, and Crash Dumps

'A log message always identifies the original cause of a failure' is incorrect because it may describe only a later symptom. 'Profiling and debugging are identical' is incorrect because profiling primarily measures execution behaviour and resource use. 'A crash dump automatically fixes a kernel failure' is incorrect because it preserves evidence for analysis.

Exam Focus: Selecting Appropriate Debugging Techniques

Distinguish logging, tracing, breakpoints, assertions, profiling, and crash dumps by their purposes and information produced. Given a deadlock, system crash, performance slowdown, or blocked I/O request, identify suitable diagnostic evidence. Questions may assess kernel versus application debugging, diagnostic overhead, saved processor state, and the importance of reproducing and isolating faults.

Key Terms of Operating System Debugging

  • Log - Record of system events.
  • Trace - Recorded sequence of execution events.
  • Breakpoint - Location where execution pauses.
  • Crash dump - Preserved state after system failure.
  • Profiling - Measurement of resource usage.
  • Debug symbol - Metadata linking code to symbols.
10
Easy
10
Medium
10
Hard

📝 All Operating system debugging techniques MCQs

Q1. A kernel developer needs to pause a running process, inspect its variables, examine the call stack, and execute instructions individually. Which debugging tool is most appropriate?

A.Compiler
B.Debugger ✅
C.Linker
D.Loader
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A debugger lets developers pause execution, inspect variables, examine call stacks, and step through instructions. These capabilities reveal runtime state and help locate logic errors that source-code inspection alone may miss.

Q2. An operating system crashes unexpectedly, and the development team wants to investigate its memory contents and execution state after the failure. Which diagnostic artifact is most useful?

A.Core dump or crash dump ✅
B.Directory listing
C.Executable installation log
D.Disk partition table
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A core dump or crash dump preserves important execution information from a process or system failure. Developers can examine memory, registers, and execution context afterward to investigate the cause without reproducing the original failure immediately.

Q3. A Linux administrator suspects that an application is repeatedly making unsuccessful file-opening requests. Which debugging technique can reveal the system calls and their returned errors?

A.CPU scheduling analysis
B.System-call tracing ✅
C.Memory compaction
D.Disk defragmentation
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: System-call tracing records interactions between an application and the kernel, including arguments and return values. Examining open-related calls and their errors helps identify incorrect paths, permission problems, missing files, or unexpected application behavior.

Q4. A database server responds slowly because one function consumes a disproportionately large amount of CPU time. Which debugging technique identifies such expensive functions?

A.Source formatting
B.File-system checking
C.Performance profiling ✅
D.Process termination
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Performance profiling measures where execution time or other resources are consumed. Developers use the collected measurements to identify expensive functions, optimize important execution paths, and avoid spending effort on code that has insignificant performance impact.

Q5. A kernel developer inserts an assertion requiring every process in the ready queue to have the READY state. What is the primary purpose of this assertion?

A.To increase CPU clock speed
B.To detect violations of expected internal conditions ✅
C.To prevent every possible process failure
D.To replace process synchronization
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Assertions verify conditions that should remain true during correct execution. Checking that ready-queue entries have the READY state can reveal scheduling or state-management defects near the point where an invariant becomes violated.

Q6. A system log records an error message without a timestamp. Why is adding timestamps particularly useful when investigating failures involving several processes?

A.It allows events from different components to be ordered chronologically ✅
B.It automatically repairs incorrect process states
C.It prevents all synchronization errors
D.It converts messages into executable instructions
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Timestamps help reconstruct the order of events across processes and kernel components. They are especially valuable when investigating intermittent failures, because developers can correlate errors, interrupts, requests, and state changes occurring close together.

Q7. A developer wants execution to stop automatically whenever a process reaches a particular source-code statement. Which debugger feature should be configured?

A.Memory allocator
B.System-call table
C.Breakpoint ✅
D.Disk interrupt
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A breakpoint pauses program execution when a specified instruction or source location is reached. Developers can then inspect the current state, evaluate expressions, and continue execution to investigate the behavior surrounding a suspected defect.

Q8. A memory-management routine occasionally changes a variable unexpectedly. A developer wants execution to stop whenever that variable is modified. Which debugging feature is most suitable?

A.Watchpoint ✅
B.File descriptor
C.Process identifier
D.Timer interrupt
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A watchpoint monitors a selected memory location and triggers when the specified access or modification occurs. It helps identify the instruction responsible for unexpected data changes without requiring developers to predict where the modification happens.

Q9. An application crashes during a function call. The developer examines the sequence of active function calls leading to the failure. Which debugging information is being examined?

A.Free-space bitmap
B.Call stack or stack trace ✅
C.Page replacement table
D.Disk request queue
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A call stack records active function calls and their execution relationships. A stack trace helps developers identify the path leading to a failure, including the functions and calling locations involved when the error occurred.

Q10. A kernel developer needs to investigate a failure on a remote computer where attaching a local interactive debugger is impossible. Which approach is commonly suitable?

A.Remote debugging through a dedicated debugging connection ✅
B.Disabling all kernel logging
C.Reinstalling the operating system after every request
D.Using a text editor to inspect live registers
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Remote debugging allows a developer to examine and control execution on another machine through a debugging connection. It is particularly useful for kernel development when local debugging is unavailable or could interfere with the target system.

Q11. A race condition occurs only occasionally when two processes update a shared counter. The problem disappears when debugging statements are added. What is the most likely explanation?

A.The debugging statements permanently eliminate mutual exclusion requirements
B.The timing changes introduced by debugging statements alter the processes' execution interleaving ✅
C.The operating system automatically disables interrupts during debugging
D.The shared counter becomes a private variable
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Race conditions depend on the timing and ordering of concurrent operations. Debugging statements can change execution timing enough to hide the original interleaving, making the failure disappear without actually correcting the synchronization defect.

Q12. A diagnostic tool constructs a wait-for graph containing P1 waiting for P2, P2 waiting for P3, and P3 waiting for P1. What does this graph indicate?

A.A circular dependency that can represent deadlock ✅
B.A valid CPU scheduling sequence
C.Successful completion of all processes
D.A normal page replacement sequence
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The graph contains the cycle P1 to P2 to P3 to P1. If these processes are blocked while waiting for one another under the represented resource conditions, the circular dependency indicates deadlock.

Q13. A tracing tool records every memory access and system call, but its output becomes extremely large and the application runs considerably slower. What is the best improvement?

A.Enable unrestricted tracing for every process permanently
B.Disable all diagnostic facilities
C.Use targeted tracing and filter events relevant to the suspected failure ✅
D.Increase the number of log messages generated
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Detailed tracing can introduce substantial execution overhead and produce excessive data. Selecting relevant processes, events, and time intervals reduces the disturbance while preserving the information needed to investigate the suspected problem.

Q14. An administrator investigates a server failure using two sources: an event log containing recorded messages and an execution trace containing detailed event sequences with timestamps. What is their main distinction?

A.Both contain only source-code comments
B.A log records selected events, while a trace can expose detailed execution sequences and relationships ✅
C.A trace always contains less information than a log
D.A log automatically reconstructs every executed instruction
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Logging records selected events chosen by developers, whereas tracing can capture detailed execution activity and event relationships. Both support diagnosis, but their depth, volume, and performance costs depend on the instrumentation.

Q15. An optimized kernel crashes, and its debugger displays instruction addresses without meaningful function names or source locations. Which additional build information would most directly help?

A.Symbol and debugging information ✅
B.Disk allocation information
C.Network routing information
D.File compression metadata
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Debugging symbols associate machine addresses with functions, variables, and source locations. Keeping suitable symbol information allows developers to interpret stack traces and crash addresses even when the executable contains optimized machine code.

Q16. A developer attaches a debugger to a production database server. The server becomes unresponsive while execution is paused. Which consideration explains why live debugging can be risky?

A.Pausing execution can disrupt timing, request handling, and coordination with other processes ✅
B.A debugger automatically deletes every database file
C.Debugging always increases CPU frequency
D.A paused process cannot retain its memory
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Live debugging can alter application timing and suspend operations that other components depend upon. In production environments, pauses can cause timeouts, service disruption, or additional synchronization problems, making controlled diagnostic methods preferable.

Q17. A program fails because a system call returns an error, but the application ignores its return value and continues using an invalid file descriptor. Which debugging improvement directly addresses this defect?

A.Increase the process scheduling priority
B.Check system-call return values and handle failures explicitly ✅
C.Disable kernel error reporting
D.Increase the disk block size
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: System calls communicate success or failure through their documented return values and error information. Checking these results allows applications to handle failures before using invalid resources or continuing with inconsistent internal state.

Q18. A performance monitor records request rates and CPU utilization: (100 requests/s, 20%) ; (200, 35%) ; (300, 52%) ; (400, 74%) ; (500, 93%). What CPU utilization is recorded at 400 requests per second?

A.0.35
B.0.52
C.0.74 ✅
D.0.93
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The recorded measurement pairs request rate with CPU utilization. At 400 requests per second, the corresponding CPU utilization is 74%, providing a reference point for investigating how workload growth affects processor demand.

Q19. A memory-monitoring utility reports allocated memory over five minutes: (0, 120 MB) ; (1, 128 MB) ; (2, 136 MB) ; (3, 144 MB) ; (4, 152 MB). What increase occurs per minute?

A.4 MB
B.6 MB
C.8 MB ✅
D.12 MB
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Allocated memory increases by 8 MB between every consecutive measurement. The constant growth rate suggests accumulating allocations, making a possible memory leak worth investigating through allocation tracking and object-lifetime analysis.

Q20. A server's measured request latencies are 10 ms, 12 ms, 14 ms, 16 ms, and 18 ms. A developer reports an average latency of 14 ms. Which calculation verifies this result?

A.(10+12+14+16+18)/5=14(10+12+14+16+18)/5 = 14 ms ✅
B.(10+12+14+16+18)/4=13.5(10+12+14+16+18)/4 = 13.5 ms
C.(10+12+14+16+18)/5=16(10+12+14+16+18)/5 = 16 ms
D.18−10=1418-10 = 14 ms
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Average latency is calculated by adding all five measurements and dividing by their count. The total is 70 milliseconds, so 70/5=1470/5=14 milliseconds represents the mean response time.

Q21. A kernel failure produces a crash dump containing processor registers, memory information, and thread states. Why are thread states particularly useful during postmortem analysis?

A.They reveal which threads were running, blocked, or waiting when the failure occurred ✅
B.They automatically identify every incorrect source-code statement
C.They show the physical location of every disk sector
D.They eliminate the need to inspect synchronization
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Thread states provide evidence about execution and synchronization at the time of failure. Examining running, blocked, and waiting threads helps developers reconstruct execution dependencies and investigate deadlocks, lock contention, and unexpected scheduling behavior.

Q22. A kernel maintains diagnostic messages in a fixed-size circular buffer. New messages overwrite the oldest entries when the buffer becomes full. Why is this design useful?

A.It guarantees unlimited historical storage
B.It provides bounded memory usage while preserving recent diagnostic information ✅
C.It prevents kernel crashes under every condition
D.It automatically converts errors into successful operations
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A circular buffer uses a fixed amount of memory and continuously retains recent messages. This is useful in kernel debugging because diagnostic logging remains available without allowing accumulated messages to consume unbounded memory.

Q23. A race detector reports that two threads access the same variable concurrently, and at least one access modifies it without synchronization. What condition is the detector identifying?

A.External fragmentation
B.A data race ✅
C.A page replacement anomaly
D.A file allocation failure
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A data race occurs when concurrent execution accesses shared memory without the synchronization required to establish a safe ordering. Such races can produce inconsistent values and unpredictable results depending on execution timing.

Q24. A kernel debugging tool reports that one execution path acquires lock L1 before L2, while another acquires L2 before L1. Why is this finding important?

A.Different lock acquisition orders can create circular waiting and deadlock ✅
B.The system has necessarily experienced a page fault
C.Both locks are guaranteed to be released immediately
D.The scheduler has permanently disabled preemption
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Inconsistent lock ordering can produce circular wait when different threads hold one lock while requesting the other. Enforcing a consistent global acquisition order helps prevent this class of deadlock.

Q25. An operating system experiences thousands of interrupts per second from one device, causing high CPU utilization and delayed application execution. Which diagnostic information is most useful initially?

A.The device interrupt counts and their rates over time ✅
B.The names of all installed text editors
C.The number of files in the user's home directory
D.The current screen resolution only
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Interrupt counters identify devices generating unusually high interrupt activity. Comparing their rates over time helps isolate interrupt storms, faulty hardware behavior, excessive interrupt generation, or inefficient device-driver handling.

Q26. A performance analyzer reports high CPU cycles and high cache-miss counts for a frequently executed kernel routine. What should the developer investigate first?

A.Whether memory access patterns are causing frequent cache misses ✅
B.Whether the routine has too many comments
C.Whether the file system uses a hierarchical directory
D.Whether the process identifier is too large
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: High cache-miss counts can indicate poor data locality, large working sets, or inefficient memory access patterns. Investigating data layout and access behavior can identify improvements that reduce memory stalls and execution time.

Q27. A scheduler trace contains three context-switch intervals: 2 microseconds, 3 microseconds, and 4 microseconds. What is their average duration?

A.2 microseconds
B.3 microseconds ✅
C.4 microseconds
D.9 microseconds
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The average context-switch duration is obtained by summing the measurements and dividing by three. Thus (2+3+4)/3=3(2+3+4)/3=3 microseconds represents the mean switching overhead for these observations.

Q28. A software update introduces a crash, but the exact change responsible is unknown. The source repository contains 32 successive revisions. Which investigation method can efficiently locate the first faulty revision?

A.Randomly modify all revisions simultaneously
B.Use binary search across revisions, testing whether the failure is present ✅
C.Delete the entire repository and rebuild the operating system
D.Disable crash reporting until the application works
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Binary search through revisions repeatedly tests a midpoint and selects the half containing the transition between working and failing versions. With 32 revisions, approximately five subdivisions can isolate the first faulty change.

Q29. A remote computer crashes during kernel initialization, before its normal network debugging service becomes available. Which diagnostic connection may still allow early-stage debugging?

A.A dedicated serial debugging connection ✅
B.A graphical file manager
C.A normal application-level network socket
D.A desktop printing interface
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A dedicated serial debugging connection can operate independently of many higher-level kernel services. It allows an external debugger to inspect early initialization failures when normal networking or graphical debugging facilities are unavailable.

Q30. A database server experiences intermittent deadlocks only under heavy I/O load. Tracing reveals that one thread holds a file-related lock while waiting for a device operation, and another holds the device-related lock while requesting the file-related lock. Which debugging conclusion is most appropriate?

A.The issue is only excessive CPU utilization
B.The two threads can form a circular wait because they acquire resources in conflicting orders ✅
C.The system necessarily has insufficient page-table entries
D.The problem can be corrected only by increasing the disk capacity
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: One thread holds the file lock while requesting the device lock, and the other holds the device lock while requesting the file lock. This circular dependency can produce deadlock under concurrent execution.

🔗 Related Topics (MCQs)