📝 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.
📝 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 Explanation: Average latency is calculated by adding all five measurements and dividing by their count. The total is 70 milliseconds, so 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 Explanation: The average context-switch duration is obtained by summing the measurements and dividing by three. Thus 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?
📖 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?
📖 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?
📖 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.