🎓 BookMCQ
← Back to 4. Threads in Operating System

📝 Threads in operating system overview (30 MCQs)

Thread Abstraction and Execution Within a Process

Threads are the smallest units of CPU execution scheduled independently within a process. Each thread has its own thread identifier, program counter, register set, and stack, while sharing the process address space, code, data, and operating system resources. Thread management belongs to process management and allows applications to perform multiple execution activities without creating an entirely separate process for each task.

Why Multiple Execution Paths Are Needed

A single-threaded process performs one sequence of instructions at a time, which can delay other activities when an operation waits for input, output, or communication. Multiple threads allow independent activities to progress concurrently while sharing common application resources. This arrangement reduces the need for separate process creation but introduces coordination requirements when threads access shared data.

Thread Creation, Scheduling, and Shared Process Resources

A process creates threads through a supported threading interface. The runtime or kernel maintains each thread's execution context and scheduling state. A scheduler selects runnable threads for available CPU cores, while context switching saves and restores thread registers and stack information. Threads access shared process memory, but their individual stacks and execution states remain separate.

Executing Two Threads Within One Application

Consider a web browser using two threads, one to process user-interface events and another to retrieve a 5 MB resource from a server. While the network operation waits for data, the interface thread can continue responding to user input. Both threads use the same process address space but maintain separate stacks and processor contexts.

Concurrency, Responsiveness, and Shared-Memory Risks

Multithreading improves application responsiveness and can increase CPU utilisation when independent activities overlap. It is useful in browsers, servers, editors, and interactive applications. However, shared memory introduces race conditions, synchronisation overhead, and possible deadlocks. The operating system must also schedule runnable threads efficiently, particularly when many threads compete for a limited number of processor cores.

Misconceptions About Threads and Processes

'Every thread has a separate process address space' is incorrect because threads within a process normally share its address space. 'Threads always execute simultaneously' is incorrect because a single-core CPU interleaves their execution. 'Creating a thread requires creating a complete new process' is incorrect because threads can share existing process resources.

Exam Focus: Thread Components and Process-Level Sharing

Distinguish process and thread resources, identifying which information is private and which is shared. Explain thread creation, scheduling, context switching, and execution states. Questions may compare single-threaded and multithreaded processes or examine how shared memory enables communication while introducing synchronisation requirements and race conditions.

Key Terms of Thread Architecture

  • Thread - Independently schedulable execution unit.
  • Thread ID - Identifier assigned to a thread.
  • Stack - Stores thread-specific execution data.
  • Concurrency - Overlapping execution activities.
  • Register set - Stores processor execution state.
  • Shared memory - Memory accessible by multiple threads.
10
Easy
10
Medium
10
Hard

📝 All Threads in operating system overview MCQs

Q1. A photo-editing application runs one thread for user input and another for image rendering. Which statement best defines a thread?

A.An independently schedulable flow of execution within a process ✅
B.A complete program with its own isolated address space
C.A copy of the entire process with separate operating-system resources
D.A hardware core that executes application instructions
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A thread is an execution path inside a process. Threads in one process share process-owned resources, while each thread retains its own execution context, allowing multiple activities to progress within the same application.

Q2. Which set of components is normally maintained separately for each thread in a multithreaded process?

A.Code section, global data, and heap
B.Program counter, CPU registers, and stack ✅
C.Process-wide open-file table and address space
D.Executable image, shared libraries, and global variables
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The program counter identifies the next instruction, registers hold the thread's current CPU values, and the stack records its active calls and local execution data. These items must remain distinct for independently progressing threads.

Q3. Which resources do threads belonging to the same process typically share?

A.Program counters and register sets
B.Private stacks and thread identifiers
C.The process address space, including code, data, and heap ✅
D.Independent execution states and stack pointers
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Threads in the same process normally use one virtual address space, so code, global data, and heap allocations are accessible to them. Each thread still has separate registers, program counter, and stack.

Q4. A student claims that threads share one stack and register set, while each thread owns a separate copy of the program code and open files. What is wrong with this claim?

A.Only program code is shared; all other resources are private
B.Stacks are shared, but registers are private to the process
C.Open files are private, but each thread shares one program counter
D.The distinction is reversed: execution context is private, while process resources are generally shared ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: The conclusion is incorrect because the stack and register state belong to individual threads, not to a shared process-wide copy. Code, global data, heap, and process-managed open files are commonly shared.

Q5. In a document editor, the user-interface thread changes a global document-status variable. Why can an autosave thread in the same process read the updated variable?

A.Both threads access the same process address space ✅
B.The operating system copies every global variable when a thread starts
C.The autosave thread inherits the user-interface thread's private registers
D.Each thread maintains a synchronized duplicate of all global data
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The changed value resides in shared process memory, so another thread using the same address space can observe it. This sharing supports communication, but simultaneous updates may require synchronization to preserve correctness.

Q6. Threads are often described as lightweight processes. What is the most accurate reason for this description?

A.A thread always uses less CPU time than a process
B.A thread cannot be interrupted while it is running
C.Threads share many process resources but retain separate execution contexts ✅
D.A thread runs without requiring memory or operating-system management
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The lightweight description refers to avoiding a separate process environment for every execution path. Threads share many process resources, but each keeps its own CPU context and stack so execution can proceed independently.

Q7. Two threads take turns running on a single-core processor. Which statement correctly describes their execution?

A.They execute instructions simultaneously on the same core
B.They execute concurrently through interleaving, but not in parallel ✅
C.They execute in parallel because they belong to one process
D.They cannot make progress unless a second core is installed
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: On one core, the processor can run only one thread at an instant. The scheduler creates concurrency by interleaving execution, so progress overlaps over time without simultaneous instruction execution on that core.

Q8. A process has two runnable threads on a four-core computer. Under what condition can both threads execute at the same instant?

A.They must use separate process address spaces
B.They must execute identical instruction sequences
C.One thread must finish before the other is scheduled
D.The scheduler assigns them to two available cores ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: If both threads are runnable and the scheduler assigns them to separate available cores, they can execute at the same instant. Sharing one process does not prevent parallel execution on multicore hardware.

Q9. A single-core server records completed requests per minute as active threads increase: (1,18), (2,31), (3,40), (4,43), (5,43), (6,42). Which interpretation is best supported by these data?

A.Throughput rises initially, then levels off as additional threads add overhead ✅
B.Throughput increases in direct proportion to the number of threads
C.A single-core processor cannot make progress on more than one request per minute
D.Six threads provide the highest measured throughput
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Throughput rises rapidly at first, reaches 43 requests per minute at four and five threads, then falls slightly. This pattern indicates saturation: extra runnable threads add scheduling overhead without improving completed work.

Q10. A file-processing application has one thread waiting for disk input while another has CPU work ready. Why can multithreading improve responsiveness in this situation?

A.The waiting thread continues executing while the disk responds
B.The disk operation is automatically converted into a CPU instruction
C.The scheduler can run the other ready thread while the first waits ✅
D.Both threads must share one program counter during the wait
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When one thread is waiting for an event such as disk completion, it cannot use the CPU productively. The scheduler may run another ready thread, allowing useful work to continue during the delay.

Q11. On a single-core CPU, an execution trace shows T1 runs from 0 to 2 ms, T2 from 2 to 5 ms, T1 from 5 to 7 ms, and T2 from 7 to 8 ms. What does this trace demonstrate?

A.T1 and T2 execute in parallel for eight milliseconds
B.The threads make concurrent progress by taking turns on one core ✅
C.T1 completes before T2 begins
D.T2 uses the CPU for only one millisecond
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The trace alternates execution between T1 and T2 on one core. Both threads make progress during the same eight-millisecond period, demonstrating concurrency; because their intervals do not overlap, it does not demonstrate parallel execution.

Q12. A process has five runnable threads on a machine with two physical cores and no simultaneous multithreading. What is the maximum number that can execute at one instant, and how many others must remain off the CPU?

A.Five executing and none off the CPU
B.Four executing and one off the CPU
C.Three executing and two off the CPU
D.Two executing and three off the CPU ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: Each physical core can execute at most one software thread at an instant under the stated assumption. Therefore, two of the five runnable threads can run simultaneously, leaving three ready but not executing.

Q13. During a context switch from one thread to another thread in the same process, which information is essential to preserve the first thread's execution point?

A.The process's entire heap contents
B.The shared code section
C.The thread's program counter, stack pointer, and CPU registers ✅
D.A duplicate of every open file
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The processor state determines where and how a thread resumes. Saving its program counter, stack pointer, and relevant registers preserves its execution context; shared code, heap data, and process file resources are not duplicated.

Q14. Three threads are ready to run in the same process. What determines which one receives the CPU next?

A.The operating system's thread-scheduling policy and current system conditions ✅
B.The order in which their source-code functions appear
C.The thread with the largest private stack
D.The order of variables in the process data section
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Runnable threads compete for processor time, and the scheduler selects among them according to the operating system's policy and current conditions. Source-code order, stack size, and variable placement do not establish execution order.

Q15. A browser tab uses one thread for interface events and another for downloading a large image. The download is waiting for network data. What benefit can this arrangement provide?

A.The interface thread must wait until the download finishes
B.The interface can remain responsive while the download thread is waiting ✅
C.The download thread transfers its stack to the interface thread
D.The browser no longer needs a scheduler
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The download thread may be blocked while waiting for network data, but the interface thread can remain runnable. Scheduling the interface thread allows the browser to respond without waiting for the network operation to finish.

Q16. A student says that switching between two threads of one process requires loading a new address space, duplicating the heap, and reopening every file. Which correction is most accurate?

A.Every thread has an independent heap, so the old heap must be discarded
B.The operating system must create a new process for every thread switch
C.A thread switch never requires saving or restoring processor state
D.The threads retain shared process resources; the switch primarily changes the execution context ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The student's description confuses a thread switch with a change of process. Threads in one process retain shared address-space and process resources, while the processor context needed by each thread is saved and restored.

Q17. A parallel application records throughput as processor cores increase: (1,40), (2,72), (3,95), (4,110), (5,116), (6,119) tasks per second. Which conclusion follows from the data?

A.Adding cores decreases throughput at every step
B.Throughput remains constant once two cores are used
C.Throughput increases, but the additional gain from each new core becomes smaller ✅
D.Six cores produce exactly six times the one-core throughput
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Throughput increases from 40 to 119 tasks per second, but successive gains shrink from 32 to 3. The measurements show diminishing returns, consistent with coordination costs or portions of work that cannot run in parallel.

Q18. A shared counter starts at 4. Thread A and Thread B both read 4, each adds 1 locally, and each writes 5. What value remains after both writes?

A.5, because one increment overwrites the other ✅
B.6, because both threads completed an increment
C.4, because simultaneous reads cancel the updates
D.7, because each thread adds one to the other thread's result
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Both threads read the same initial value, 4, before either writes. Each therefore computes 5, and the later write replaces the earlier one. The final value is 5, showing a lost update.

Q19. Two threads independently call the same recursive function at the same time. Why can each call maintain its own return addresses and local variables?

A.Each thread receives a separate copy of the program code
B.The operating system creates a separate process for every recursive call
C.Recursive functions store all local variables in shared global memory
D.Each thread has its own stack for active function calls ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Each thread uses its own stack to record function-call frames, return addresses, and local variables. The threads can execute the same code while preserving separate call histories and independent points of execution.

Q20. A service must process 12 independent CPU-bound jobs. Each job needs 3 ms of CPU time, and four cores are available. Assuming perfect balancing and no overhead, what is the ideal completion time?

A.3 ms
B.9 ms ✅
C.12 ms
D.36 ms
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Four cores can process four jobs simultaneously. Twelve jobs therefore require 12/4=312 / 4 = 3 waves; each wave takes 3 ms, giving an ideal completion time of 3×3=93 \times 3 = 9 ms.

Q21. An intern argues that because every thread has a private stack, a multithreaded process contains no data that can be accessed by more than one thread. What is the flaw?

A.Private stacks are actually shared by all processes
B.Registers are the only data that threads can access
C.Global variables and heap objects are generally shared within the process ✅
D.Each thread receives a different copy of every global variable
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A private stack separates each thread's active calls and local stack data, but it does not isolate the process's address space. Threads can still access shared global variables, heap objects, and other process resources.

Q22. Which identifier is used to distinguish one thread from other threads managed within a process or system?

A.Thread identifier ✅
B.Stack address shared by every thread
C.Process executable filename
D.Global variable address
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A thread identifier provides a way for the operating system or threading environment to refer to a particular thread. It is distinct from the process identifier, which identifies the process that owns the thread.

Q23. What is the main communication advantage of threads sharing one process address space?

A.They no longer need to execute instructions to exchange information
B.They are prevented from accessing the same variable simultaneously
C.Every shared variable is automatically protected from inconsistent updates
D.They can communicate through shared memory without separate interprocess data transfer ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Because threads share an address space, one thread can place data in memory that another thread can access directly. This can simplify communication, although concurrent modifications still require appropriate coordination.

Q24. A student claims that a race condition cannot occur on a single-core processor because only one thread executes at any instant. Which reasoning identifies the error?

A.Race conditions require two separate physical processors
B.A scheduler can interleave the separate steps of non-atomic operations ✅
C.A single core executes every instruction from one thread without interruption
D.Shared variables are automatically locked whenever a thread is preempted
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The claim overlooks interleaving. A thread can be interrupted after reading shared data but before writing its result; another thread may perform the same steps, producing an incorrect outcome even on one core.

Q25. Thread A holds lock L1 and waits for L2, while Thread B holds L2 and waits for L1. Which problem can prevent both threads from making progress?

A.Deadlock caused by circular waiting ✅
B.Parallel execution on separate cores
C.A context switch that restores the wrong program counter
D.A thread using its private stack
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Each thread waits for a lock held by the other, creating a circular wait. Neither can proceed to release its lock, so both remain blocked until some external action breaks the deadlock.

Q26. Three threads each perform one unsynchronized increment of shared integer X, initially 0. Each increment consists of separate read, add, and write steps, and switching may occur between any steps. What is the smallest possible final value after all threads finish?

A.0
B.2
C.1 ✅
D.3
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: All three threads can read 0 before any writes occur. Each then adds one and writes 1, so the final value can be 1. No completed increment writes a value below 1, making 1 the minimum.

Q27. A program creates 100 short-lived threads for 100 tiny CPU tasks on a two-core machine. Why could this design perform worse than using fewer long-lived execution threads?

A.The processor must execute all 100 threads simultaneously
B.Thread creation and context-switching costs may exceed the useful work ✅
C.A process can contain only two threads on a two-core machine
D.Short-lived threads always execute at a lower clock frequency
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: When each task performs little work, creating and scheduling many threads can consume more time than the tasks themselves. Thread-management overhead and frequent context switches may therefore reduce total throughput.

Q28. A data-analysis application divides independent records among worker threads. The workers also update one shared summary value. Which design concern combines the benefit and risk of threads?

A.Shared memory prevents workers from accessing the summary
B.Each worker must use a separate executable file
C.The summary is copied automatically after every update
D.Shared memory makes the summary accessible, but concurrent updates need coordination ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: Shared address space lets workers contribute to one summary without separate process communication. However, simultaneous read-modify-write operations can overwrite one another, so the update must be protected or made atomic.

Q29. Why can adding more runnable threads to a CPU-bound application eventually reduce performance?

A.More threads permanently reduce the number of processor cores
B.Every thread forces the operating system to duplicate the entire process
C.Scheduling and context-switching overhead can outweigh useful parallel work ✅
D.A thread cannot execute after another thread has completed
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Additional threads can expose more parallel work, but they also require scheduling and processor-state switching. Once available cores are saturated, excess runnable threads may add overhead without increasing useful CPU capacity.

Q30. A process runs on a two-core machine. Thread T1 is running on core 0, T2 is ready, and T3 is blocked waiting for network data. Which statement is correct?

A.T2 may be dispatched on core 1; T3 cannot run until its awaited event occurs, and all three threads share process resources ✅
B.T3 may run immediately because a blocked thread always receives priority over a ready thread
C.T2 cannot run until T1 terminates because both threads belong to the same process
D.T1, T2, and T3 each require a separate process address space before execution
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: T1 is using one core, while T2 is eligible for another available core. T3 is blocked and cannot run until its event completes; nevertheless, all three threads remain within the same process and share its resources.

🔗 Related Topics (MCQs)