📝 Introduction to Kernel Data Structures in Operating Systems (30 MCQs)
Kernel Information Structures and System State Management
Kernel data structures organise the information required to manage processes, memory, files, devices, and other operating system resources. They allow kernel routines to locate, update, and coordinate system objects efficiently. Common structures include linked lists, queues, trees, hash tables, bitmaps, and arrays. Their selection affects lookup speed, allocation overhead, memory consumption, and the complexity of maintaining consistent system state.
Why Efficient Data Organisation Matters in Kernel Operations
The kernel frequently searches for processes, tracks available memory frames, manages open files, and handles pending I/O requests. Poorly chosen structures can increase lookup time or make updates expensive, particularly under heavy workloads. Different operations require different access patterns, so the kernel selects structures according to search frequency, insertion and deletion costs, ordering requirements, and concurrency constraints.
Lists, Queues, Trees, Hash Tables, and Bitmaps
Linked lists connect dynamically allocated elements and support flexible insertion and removal. Queues organise requests in arrival or priority order, while balanced trees support ordered searches and updates. Hash tables provide efficient average-case lookup through computed keys. Bitmaps represent resource availability using individual bits, and arrays provide direct indexing when identifiers or positions are suitably organised.
Tracking Free Memory Frames with a Bitmap
Suppose physical memory contains 64 frames, and each bitmap bit represents one frame. A bit value of zero may indicate a free frame, while one indicates an allocated frame, according to the implementation's convention. The memory manager searches for a zero bit, marks the corresponding frame allocated, and updates the bitmap when that frame becomes free.
Lookup Complexity, Memory Overhead, and Concurrency
Appropriate data structures reduce search and update costs in heavily used kernel paths. Hash tables can provide average-case constant-time lookup, while balanced search trees offer logarithmic operations. However, collisions, resizing, locking, and memory allocation introduce overhead. Concurrent kernel operations also require synchronisation to prevent inconsistent updates, making correctness as important as algorithmic efficiency.
Misconceptions About Kernel Data Structure Behaviour
'A linked list always provides faster searching than an array' is incorrect because linked-list searches are generally linear, while indexed arrays provide direct access. 'A hash table guarantees constant-time lookup' is incorrect because collisions can increase search costs. 'A bitmap stores complete resource descriptions' is incorrect because it primarily represents states using individual bits.
Exam Focus: Data Structure Selection and Complexity
Be prepared to select suitable structures for ready queues, free-frame tracking, process lookup, and ordered resource management. Calculate bitmap storage requirements and compare the search, insertion, and deletion complexities of arrays, lists, queues, trees, and hash tables. Questions may also examine collision handling, resource-state updates, and synchronisation during concurrent kernel operations.
Key Terms of Kernel Data Structures
- Linked list - Dynamically connected collection of elements.
- Queue - First-in-first-out ordered collection.
- Tree - Hierarchical structure of connected nodes.
- Hash table - Key-based structure supporting fast lookup.
- Bitmap - Compact representation of resource states.
- Collision - Multiple keys sharing a hash location.
📝 All Introduction to Kernel Data Structures in Operating Systems MCQs
Q1. A kernel needs to maintain information about every active process, including its state, saved registers, program counter, scheduling information, and allocated resources. Which data structure represents this information for an individual process?
📖 Explanation: A process control block stores execution state, saved registers, program counter, scheduling information, and resource references needed to manage a process. The tempting source-code option is wrong because code is not process-control metadata.
Q2. A kernel maintains several runnable processes waiting for CPU time. Which data structure is most appropriate for managing processes that should be dispatched in arrival order?
📖 Explanation: A ready queue contains runnable processes waiting for processor service. FIFO removes the earliest enqueued process first. The tempting wait-queue option is wrong because blocked processes cannot run until their awaited event occurs.
Q3. A kernel frequently inserts and removes process descriptors from a collection. It already has a pointer to the descriptor being removed. Which structure supports efficient insertion and deletion when the relevant node is already known?
📖 Explanation: A doubly linked list allows insertion and deletion in constant time when the target node is already known. The tempting array option generally requires shifting elements after removal, making such updates more expensive.
Q4. A kernel frequently searches for a process using its unique process identifier. Which data structure can provide efficient average-case lookup when an appropriate hash function is available?
📖 Explanation: A hash table maps process identifiers to locations using a hash function, supporting efficient average-case lookup. The tempting linear-array option requires scanning entries individually and becomes increasingly expensive as the process collection grows.
Q5. A kernel manages 8192 physical memory frames and maintains one bit for each frame to indicate whether it is available or occupied. Which structure is being used?
📖 Explanation: A bitmap represents each frame using one bit indicating whether it is free or occupied. The tempting linked-list option can track free frames, but it does not provide the specified one-bit-per-frame representation.
Q6. A processor handles an interrupt while another kernel operation is already executing. The kernel must preserve the current sequence of execution and later resume it correctly. Which data structure naturally supports this nested execution state?
📖 Explanation: A stack follows last-in, first-out ordering, making it suitable for nested function calls and saved execution contexts. The tempting queue option removes entries in arrival order and cannot directly support nested return sequencing.
Q7. A kernel receives file descriptor 12 from an application and must locate the corresponding open-file information efficiently. Which structure normally maps this descriptor number to an open-file object?
📖 Explanation: A process file descriptor table maps descriptor numbers to references to open-file objects. The tempting ready-queue option manages runnable processes, not file references; descriptor lookup uses the process-associated table.
Q8. A kernel implements a fixed-size circular buffer for incoming device events. The implementation reserves one array slot to distinguish a full buffer from an empty buffer. If the array contains 16 slots, how many events can it hold simultaneously?
📖 Explanation: Reserving one slot avoids ambiguity between equal head and tail positions, leaving usable slots. The tempting 16-event answer assumes an additional count or full indicator is maintained.
Q9. A kernel must maintain relationships between parent processes and their child processes. Which structure most naturally represents these hierarchical relationships?
📖 Explanation: A tree represents parent-child relationships through hierarchical nodes and edges. The tempting hash-table option supports key-based lookup, but it does not inherently preserve the parent-child organization needed to navigate process ancestry.
Q10. Several kernel threads are sleeping while waiting for a particular disk operation to complete. Which kernel data structure helps organize these sleeping threads until the relevant event occurs?
📖 Explanation: A wait queue holds threads sleeping until a specified event or condition becomes satisfied. The tempting ready-queue option contains runnable threads, whereas these threads cannot execute until their awaited disk operation completes.
Q11. A system maintains a bitmap for 32768 physical memory frames, using exactly one bit per frame. How many bytes are required for this bitmap?
📖 Explanation: Each frame needs one bitmap bit, so 32768 frames require 32768 bits. Dividing by eight gives 4096 bytes, equal to 4 KiB. The tempting 32768-byte answer treats bits as bytes.
Q12. A kernel uses a circular queue with eight array slots and reserves one slot to distinguish full from empty. After six successful insertions without removals, what is the queue's remaining usable capacity?
📖 Explanation: The queue can hold seven elements because one of its eight slots is reserved. After six insertions, only one usable position remains; the tempting two-element answer incorrectly assumes all eight slots are available.
Q13. A kernel maintains process descriptors in a doubly linked list. It receives a pointer to a descriptor that must be removed. Assuming valid neighboring pointers, what is the time complexity of removing that descriptor?
📖 Explanation: With a pointer to the target node, the kernel updates its previous and next links directly. This requires constant work, ; the tempting linear-time answer includes searching for the node, which is unnecessary.
Q14. A kernel uses the hash function to organize process identifiers. Three identifiers are 12, 17, and 22. Which bucket receives all three identifiers when separate chaining is used?
📖 Explanation: All three identifiers have remainder two when divided by five: , , and . Therefore bucket 2 contains their chain; the tempting bucket 4 has no matching remainder.
Q15. A kernel stores memory-region descriptors in a balanced binary search tree. A process has 4095 descriptors. What is the expected worst-case search complexity for locating a descriptor by its ordered key?
📖 Explanation: A balanced search tree maintains logarithmic height, so finding a descriptor requires examining approximately nodes. The tempting linear-time option describes an unbalanced or sequential structure rather than a balanced tree.
Q16. A kernel scheduler must repeatedly insert runnable tasks and remove the highest-priority task. Which data structure is particularly suitable when efficient priority-based insertion and extraction are required?
📖 Explanation: A binary heap maintains priority ordering while supporting insertion and removal of the highest-priority element in logarithmic time. The tempting FIFO queue selects by arrival order, not by priority.
Q17. Two kernel subsystems share a reference-counted memory object. Its reference count is initially two. One subsystem releases its reference. What should the kernel do?
📖 Explanation: Releasing one of two references changes the count from two to one, so another subsystem still owns it. The tempting immediate deletion is incorrect because the object must remain available until its reference count reaches zero.
Q18. A kernel implements a single-producer, single-consumer ring buffer. The producer writes event data into a free slot and then advances the published write index. Why must the data be stored before the index is published?
📖 Explanation: Publishing the index after storing data ensures the consumer does not read an incomplete event. The tempting reverse ordering can expose uninitialized contents, especially when compiler or processor memory reordering occurs.
Q19. A kernel monitoring tool records the number of entries in a wait queue: Time 0: 3 entries ; Time 1: 5 entries ; Time 2: 8 entries ; Time 3: 6 entries ; Time 4: 4 entries. At which time is the queue longest?
📖 Explanation: The recorded queue length reaches its maximum of eight entries at time 2. The tempting time 3 answer identifies a later measurement, but the queue has already decreased from eight to six entries.
Q20. A kernel uses a hash table with six buckets to store 18 process-related objects. Assuming uniform distribution, what is the average load factor?
📖 Explanation: The load factor is the number of stored entries divided by the number of buckets: . This means three entries per bucket on average; the tempting six reverses the ratio.
Q21. A kernel hash table uses separate chaining. Due to a poor hash function, every one of its 1000 entries maps to the same bucket. What is the worst-case lookup complexity?
📖 Explanation: When every entry maps to one bucket, lookup may require examining all 1000 chained entries. Its worst-case complexity becomes ; the tempting constant-time answer assumes collisions remain sufficiently distributed.
Q22. A kernel stores non-overlapping virtual memory regions in a balanced search tree, ordered by starting address. It searches for the region containing a specified virtual address. Which approach gives the appropriate search complexity?
📖 Explanation: Because regions are ordered and non-overlapping, the kernel can find the greatest starting address not exceeding the target using a balanced-tree search. Checking its endpoint determines containment; scanning every region is unnecessarily linear.
Q23. Two processors simultaneously scan a kernel free-frame bitmap and both observe that frame 40 is available. Both attempt to allocate it. Which mechanism prevents both processors from successfully claiming the same frame?
📖 Explanation: An atomic test-and-set or correctly protected bitmap update ensures only one processor claims the available frame. The tempting ordinary bit check is insufficient because both processors may observe the same old value concurrently.
Q24. A kernel developer inserts node N between nodes A and B in a singly linked list. The developer executes A.next=N followed by N.next=A.next. What is the error?
📖 Explanation: The flawed step overwrites A.next before preserving B, so N.next subsequently points to N itself. The correct order saves the old successor first, assigns N.next to B, then changes A.next to N.
Q25. A circular queue has six array slots. Its front index identifies the first item, and its tail identifies the next insertion position. Initially front=4, tail=4, count=0. The kernel enqueues A, B, and C, dequeues A, then enqueues D and E. Which state is correct?
📖 Explanation: Insertions occupy indexes 4, 5, and 0, advancing tail to 1. Removing A advances front to 5; inserting D and E advances tail to 3, leaving four entries.
Q26. A kernel hash table records chain lengths as follows: Bucket 0: 2 entries ; Bucket 1: 5 entries ; Bucket 2: 1 entry ; Bucket 3: 4 entries ; Bucket 4: 3 entries. Which bucket requires the most node examinations for a complete unsuccessful chained lookup?
📖 Explanation: An unsuccessful lookup in separate chaining examines every entry in the selected bucket. Bucket 1 has five entries, the largest chain shown; the tempting bucket 3 contains only four entries.
Q27. A multicore kernel maintains a separate runnable-task queue for each processor instead of placing all tasks in one global queue. What is the main benefit of this organization?
📖 Explanation: Per-processor queues reduce contention because processors can manipulate their local runnable-task structures independently. The tempting global-lock design increases coordination; load balancing may still be needed when one processor becomes overloaded.
Q28. A kernel thread is interrupted during a function call, and a nested interrupt handler executes before the original handler completes. Why does the kernel maintain an appropriate kernel stack for each executing thread?
📖 Explanation: A kernel stack preserves function frames, return addresses, and local variables during nested execution. The tempting file-storage option confuses execution context with persistent file metadata, which belongs in separate kernel structures.
Q29. A kernel manages 1024 physical blocks using a two-level bitmap. Each second-level bitmap word describes 32 blocks, and one summary bit indicates whether each word contains a free block. The summary identifies word 19, whose first available position is bit 7. Which block number is free, using zero-based indexing?
📖 Explanation: Word 19 covers blocks starting at . Adding bit position 7 gives . The tempting 607 subtracts instead of adding the zero-based position within the identified word.
Q30. A process descriptor participates simultaneously in the kernel's global process list and its parent's child-process list. Why might the descriptor contain separate linked-list pointers for these relationships?
📖 Explanation: Separate linkage fields allow the same descriptor to participate in multiple independent lists simultaneously. Reusing one pair of pointers would corrupt one relationship when the other list changes; the tempting single-link design is unsafe.