🎓 BookMCQ
← Back to 4. Threads in Operating System

📝 Windows Threads in operating system (33 MCQs)

Windows Thread Architecture and Kernel Scheduling

Windows threads are the primary units of CPU scheduling within Windows processes. Each thread maintains its own execution context, including a stack, register state, scheduling information, and thread identifier, while sharing the process address space and handles to process resources. The Windows kernel manages thread states, dispatching, priorities, and synchronisation through operating system objects and scheduling facilities.

Why Windows Separates Threads from Process Resources

A Windows process provides a protected resource container, but applications often need several independent activities within that container. Separate threads enable concurrent operations while sharing memory, files, and other process resources. This arrangement supports responsive interfaces and server applications without requiring every task to maintain an independent process address space.

Thread Creation, Scheduling, and Synchronisation Objects

Windows applications can create threads using functions such as CreateThread() or the commonly used _beginthreadex() for C runtime-aware applications. The kernel maintains thread objects and schedules ready threads according to priority and processor availability. Synchronisation objects such as mutexes, semaphores, events, and critical sections coordinate access to shared resources and execution dependencies.

Launching Two Workers in a Windows Process

Consider a Windows application that creates two worker threads using _beginthreadex(). One processes the first half of a 100 MB file, while the other processes the remaining portion. Both threads share the process address space but use separate stacks. The application waits for both handles to become signalled before combining their results.

Priority Scheduling, Handle Management, and Thread Costs

Windows threads support parallel execution, responsive applications, and concurrent background tasks. Priority-based scheduling influences CPU allocation, while synchronisation objects help control access to shared resources. However, excessive thread creation increases kernel object and stack overhead. Incorrect priority selection may cause starvation-like delays, while failure to manage thread handles can retain unnecessary system resources.

Misconceptions About Windows Process and Thread Objects

'A Windows process is the unit directly scheduled on a CPU' is incorrect because its threads are scheduled. 'Every Windows thread has a separate process address space' is incorrect because process threads normally share that space. 'A thread handle is the thread execution context' is incorrect because the handle references a kernel-managed object.

Exam Focus: Windows Thread Creation and Synchronisation

Distinguish Windows process objects from thread objects and explain the thread scheduling role of the kernel. Recognise CreateThread(), _beginthreadex(), and common synchronisation objects. Questions may examine thread handles, priority levels, shared address spaces, waiting for thread completion, and why multiple threads within one process can execute on different processor cores.

Key Terms of Windows Threading

  • Thread object - Kernel-managed thread representation.
  • CreateThread() - Windows function creating a thread.
  • Thread handle - Reference to a thread object.
  • Priority - Scheduling importance assigned to a thread.
  • Critical section - Synchronisation for shared resources.
  • Event object - Kernel object used for notification.
11
Easy
11
Medium
11
Hard

📝 All Windows Threads in operating system MCQs

Q1. Which characteristic most directly distinguishes a Windows thread from its process?

A.a thread is an execution unit within a process and shares its process address space ✅
B.a thread owns an independent copy of every process resource
C.a thread always executes in a separate virtual address space
D.a thread cannot coexist with other threads in its process
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A process provides resources such as a virtual address space and handles, while its threads execute instructions within it. Threads generally share process memory and resources but maintain separate execution contexts.

Q2. A Windows process has three threads. One changes a global configuration value, and the others read it. Why can they access the same variable?

A.each thread receives a fresh copy whenever a write occurs
B.the threads use separate address spaces connected through the file system
C.threads in one process share the same virtual address space ✅
D.Windows merges the threads into one execution stream
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Threads in one process normally share its virtual address space, including global variables and heap objects. A write by one thread can therefore be observed by another, although synchronization is needed for safe concurrent access.

Q3. A developer assumes a new Windows thread receives a private copy of the process heap. Which correction is accurate?

A.only the first thread can allocate dynamic memory
B.threads generally share the process heap, while each thread has its own stack and execution context ✅
C.Windows duplicates the entire heap whenever a thread starts
D.all threads in a process use one shared stack
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A Windows thread has its own stack and processor context, but threads in one process generally share the process heap and address space. Dynamically allocated objects may therefore be accessed by multiple threads and require coordination.

Q4. A worker dereferences an invalid pointer and raises an unhandled exception. Which conclusion about the other threads is safest?

A.the other threads are guaranteed to continue normally
B.only the worker's stack is destroyed in every case
C.Windows always restarts the worker with its previous registers
D.the exception may terminate the process, so survival of other threads is not guaranteed ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: An unhandled exception in a thread can terminate the entire process, depending on the exception and handling mechanisms. It is unsafe to assume that only the faulting thread disappears or that remaining threads continue normally.

Q5. Several threads increment one shared counter using separate read, add, and write steps without synchronization. Which result is possible?

A.some increments may be lost when operations interleave ✅
B.the operating system automatically serializes every increment
C.the counter becomes private to the last thread
D.the final value must equal the number of increments
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A read-modify-write increment is not necessarily atomic. Two threads may read the same old value and both write the same new value, losing an increment. Use an atomic operation or synchronization to protect the update.

Q6. A Windows thread routine expects a pointer to a request structure, but the creator passes an integer address with an unrelated layout. What is the main risk?

A.Windows automatically converts the argument into the intended structure
B.the thread cannot be scheduled until the address is freed
C.the routine may interpret incompatible data, causing invalid access or incorrect behavior ✅
D.the new thread receives the creator's return value instead
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The start routine must interpret its argument using the agreed type and layout. Passing an incompatible pointer can produce invalid values or unsafe memory access; Windows does not infer the intended structure or repair the mismatch.

Q7. When creating a Windows thread with CreateThread, which information is essential to specify the code where the new thread begins?

A.the process identifier of a different application
B.the starting address of the thread procedure ✅
C.the address of the process heap only
D.the handle of the thread that will eventually join it
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: CreateThread requires a start address identifying the code the new thread will execute, along with other creation parameters. The thread procedure receives its parameter when it begins, while the scheduler determines when it runs.

Q8. A program calls CreateThread successfully and immediately assumes the new thread has already completed its first instruction. What is the error?

A.successful creation makes the creator wait automatically
B.the new thread always runs before the creator resumes
C.the scheduler runs new threads only after process termination
D.creation makes the thread eligible, but does not guarantee when it will execute ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: A successful creation call does not establish a precise execution order. The new thread becomes eligible to run, but scheduling may let the creator continue first or may dispatch the new thread immediately.

Q9. CreateThread returns a thread HANDLE and a thread identifier. Which statement correctly distinguishes them?

A.the handle refers to the thread object for APIs, while the identifier is a numeric identity ✅
B.the identifier is used to wait on the thread, while the handle is its process address
C.both values are interchangeable pointers to the thread stack
D.the handle is the thread's exit code and the identifier is its priority
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A thread handle is a reference to a thread object that can be used with APIs requiring a handle and suitable access rights. A thread identifier is a numeric identity, not a substitute for that handle.

Q10. A Windows service closes a worker's thread handle while the worker is still executing. What normally happens?

A.the worker is terminated immediately
B.the worker loses its stack but continues running
C.the handle reference is released, but the thread may continue executing ✅
D.the entire process exits when the handle is closed
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Closing a thread handle releases that handle reference; it is not a termination request. If the worker is still running and no other action stops it, execution may continue after the handle is closed.

Q11. A worker terminates, and another thread is waiting on its thread handle. What does the completed wait indicate?

A.the process has necessarily terminated
B.the thread object has become signaled because the worker terminated ✅
C.all handles in the process have been closed
D.the worker has been scheduled for the first time
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When a Windows thread terminates, its thread object becomes signaled. A thread waiting on that handle can then proceed, which provides a completion notification without implying that the entire process has ended.

Q12. A Windows worker returns from its thread procedure. Which event normally follows?

A.the process is always terminated, even when other threads remain
B.the thread is automatically restarted with the same parameter
C.all other threads are forced to join it
D.the calling thread terminates and its thread object becomes signaled ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Returning from the thread procedure terminates that thread. Its thread object becomes signaled, allowing waiters to proceed; the process continues if other threads remain active and no process-wide termination occurs.

Q13. A developer assumes each thread shares one stack because all threads share the process address space. Which analysis is correct?

A.each thread normally has its own stack within the shared process address space ✅
B.all threads must use the same stack pointer
C.Windows creates a separate process for every stack
D.stacks are shared only when threads use different processor cores
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Threads share the process virtual address space, but each normally has its own stack for calls, local variables, and return addresses. Shared address-space membership does not mean their stack pointers or stack contents are identical.

Q14. A developer suspends a worker while it holds a mutex, expecting the mutex to become available. What is the likely risk?

A.suspension automatically releases every lock owned by the worker
B.Windows transfers the mutex to the suspending thread
C.other threads needing that mutex may remain blocked while the worker is suspended ✅
D.the worker completes its procedure before suspension takes effect
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Suspending a thread can freeze it while it owns a mutex or another resource. Threads that need that resource may then block, potentially causing deadlock; suspension is not a safe replacement for cooperative shutdown.

Q15. A user-interface thread owns a window control, while a worker computes an update. The framework requires control access on the owning thread. What should the worker do?

A.modify the control directly because memory is shared
B.post or marshal the update to the user-interface thread ✅
C.terminate the user-interface thread before writing
D.copy the control into its private stack
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A shared address space does not make every operation valid from every thread. When a framework requires UI access on the owning thread, the worker should post or marshal an update so that the UI thread performs it.

Q16. A service stores a temporary request identifier in thread-local storage. What benefit does this provide?

A.all threads update one shared identifier atomically
B.the identifier is copied into every process
C.the identifier remains global after the thread exits
D.each thread has a separate instance of the identifier ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Thread-local storage gives each thread a distinct instance of a variable. It suits per-thread state such as request identifiers, but does not synchronize separate shared objects or make other process data automatically thread-safe.

Q17. A Windows application creates thousands of threads that mostly wait for network responses. CPU use remains low, but memory use rises. Which explanation is most reasonable?

A.waiting threads still require thread objects, stack resources, and bookkeeping ✅
B.every waiting thread reserves one physical processor core
C.the process heap is duplicated for every thread
D.blocked threads continuously execute at full CPU speed
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A waiting thread may consume little processor time but still has an object, stack reservation, and management state. Large thread populations can therefore raise memory use and system overhead even when most threads are blocked.

Q18. A program creates a new Windows thread for every tiny task. Measurements show creation and scheduling overhead dominate useful work. Which redesign is most appropriate?

A.increase the number of short-lived threads further
B.give every task a separate process
C.reuse a bounded set of worker threads to process queued tasks ✅
D.make every worker poll continuously for new tasks
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Short-lived threads can make creation, termination, and scheduling costs large relative to useful work. A bounded worker pool reuses existing threads, limits active concurrency, and can reduce overhead for many small tasks.

Q19. A thread uses an atomic increment on a shared counter, but reads a separate shared flag without synchronization. Which conclusion is correct?

A.the atomic increment protects every variable in the process
B.the flag still needs its own suitable atomic or synchronization protocol ✅
C.the flag becomes thread-local automatically
D.atomic operations prevent all possible data races in unrelated code
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Atomicity applies only to the operations and memory-ordering guarantees provided by the particular atomic mechanism. It does not protect unrelated variables or multi-step invariants, so the separate flag requires its own safe access protocol.

Q20. A worker must stop when a user presses Cancel, but it may be processing a valid request. Which shutdown design is generally safest?

A.terminate the thread abruptly at any instruction
B.suspend the worker and assume locks are released
C.close its thread handle and treat that as cancellation
D.request cooperative cancellation and let the worker clean up before exiting ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: Cooperative cancellation lets a worker observe a stop request, finish or abandon work safely, and release resources. Abrupt termination or indefinite suspension can leave shared state inconsistent and locks or other resources held.

Q21. A developer raises a worker's priority to fix a slow application, but the interface becomes less responsive. What is the likely explanation?

A.the worker's higher priority can compete more aggressively for CPU time ✅
B.raising priority automatically reduces the number of cores
C.Windows stops scheduling the worker when its priority increases
D.the interface thread becomes a separate process
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A higher-priority worker may receive processor time more aggressively when runnable. If it competes with the interface thread on limited cores, UI responsiveness can deteriorate; priority changes should be measured rather than applied indiscriminately.

Q22. A thread repeatedly checks a Boolean flag until another thread changes it, consuming nearly one core while waiting. Which improvement is best?

A.increase the polling frequency
B.create additional polling threads
C.use an event or another blocking synchronization mechanism ✅
D.make the flag local to the waiting thread
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Busy waiting repeatedly consumes processor time while the desired condition is unavailable. An event or other blocking mechanism lets the thread sleep until notified, reducing wasted CPU use and often improving overall responsiveness.

Q23. A main thread needs a worker's result only after the worker has finished. Which sequence is appropriate?

A.read the result immediately after CreateThread returns
B.wait for the worker to terminate, then read the result using the defined synchronization protocol ✅
C.close the process handle before the worker writes
D.suspend the worker and inspect its stack
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Waiting for worker termination provides a clear completion point before the result is consumed. The program must still respect shared-data synchronization and object lifetime; thread creation alone does not prove that the result is ready.

Q24. One thread locks a mutex and updates a shared balance. A second thread reads the balance without locking. Which statement is correct?

A.the mutex protects all accesses automatically, including unprotected reads
B.reads can never conflict with writes
C.the first unlock makes the balance permanently immutable
D.the unprotected read may race; conflicting accesses must follow a consistent synchronization strategy ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: A mutex coordinates only code that follows the same locking protocol. A reader that accesses the balance without acquiring the mutex or using another valid mechanism can observe inconsistent data or participate in a data race.

Q25. Several Windows worker threads remove items from one shared queue. Which design prevents two workers from removing the same item?

A.protect the relevant queue operations with a lock or use a correctly designed concurrent queue ✅
B.let every worker read and remove items without coordination
C.copy the queue pointer into each worker's stack and ignore updates
D.disable memory allocation while leaving queue operations unsynchronized
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A shared queue must coordinate operations that inspect and remove items. A lock can make the removal sequence mutually exclusive, while a suitable concurrent queue provides defined thread-safe behavior; shared memory alone does not prevent duplicate removal.

Q26. A Windows application becomes unresponsive during a long calculation on its only thread. The developer proposes splitting the calculation among workers. What should be evaluated first?

A.whether four threads always guarantee fourfold speedup
B.whether every worker can safely update shared data without coordination
C.whether the calculation contains independent work and whether coordination overhead is justified ✅
D.whether error handling can be removed after adding threads
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Parallel decomposition helps when useful work can execute independently or be divided with manageable coordination. Serial dependencies may prevent speedup, and synchronization adds overhead, so the workload should be analyzed and measured before redesign.

Q27. The main thread waits for a worker to finish, while that worker waits for an event that only the main thread will signal after its wait returns. What problem exists?

A.false sharing between two variables
B.a circular dependency that can prevent both threads from progressing ✅
C.a harmless priority difference
D.automatic thread-pool expansion
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The main thread cannot signal the event until its wait returns, while the worker cannot finish until the event is signaled. This circular dependency prevents progress and can cause deadlock; the completion protocol must be redesigned.

Q28. An image contains 12,000 independent pixels that need the same operation. A program uses four balanced workers. Which design best fits the workload?

A.each worker repeatedly processes all pixels and overwrites the same output
B.create a separate process for every pixel
C.assign every pixel to the user-interface thread
D.divide the image into disjoint regions and assign one region to each worker ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Independent pixel operations can be divided among workers using disjoint regions. Balanced assignments reduce idle time, while separate output locations avoid conflicting writes; the design must still account for any dependencies at region boundaries.

Q29. Two workers spend most of their time waiting for the same exclusive mutex, and adding workers does not improve throughput. Which redesign is most promising?

A.shorten the critical section or partition shared state to reduce lock contention ✅
B.remove the mutex even if updates can become inconsistent
C.raise every worker to the highest priority
D.increase the number of workers without changing the protected code
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A single exclusive lock serializes access to the protected region, limiting parallel progress. Shortening the critical section or partitioning state can reduce contention, whereas removing necessary synchronization risks corrupting shared data.

Q30. A service creates a new thread for every request. During traffic spikes, memory use and context-switching overhead rise sharply. Which change addresses the root cause?

A.create two additional threads for every existing thread
B.raise all worker priorities
C.use a bounded worker pool, queue excess requests, and apply backpressure when capacity is reached ✅
D.replace all workers with an infinite polling loop
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Creating a thread for every request can cause excessive resource use during bursts. A bounded pool limits active concurrency, while queuing and backpressure manage excess requests and keep memory and scheduling costs under control.

Q31. A scheduler saves a Windows thread's instruction pointer, registers, and stack position before switching away. What do these values represent together?

A.the complete executable image of the process
B.the thread's execution context needed to resume its instruction stream ✅
C.the shared heap contents of every process
D.the security permissions of every system object
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A thread's execution context includes its instruction position, registers, and stack state. Preserving this information allows the scheduler to resume the thread from its previous point rather than restarting its computation.

Q32. A shared variable sometimes appears stale in another Windows thread even though both use the same address space. What is the appropriate response?

A.assume the scheduler always runs the writer first
B.duplicate the entire process for every read
C.increase the variable's value until stale reads disappear
D.establish suitable synchronization or atomic access instead of assuming shared memory guarantees ordering ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: A shared address space makes data accessible but does not by itself define safe ordering or atomicity. A correct synchronization protocol or suitable atomic operations are needed to make concurrent updates and their visibility reliable.

Q33. A worker has finished and its thread handle remains open. Which statement about the thread object is most accurate?

A.the thread object may remain until its outstanding handles are closed ✅
B.the thread object must be destroyed immediately at function return
C.the process heap is freed when the thread handle remains open
D.the handle changes into a thread identifier automatically
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Thread termination makes the thread object signaled, but the object can remain while handles are still open. Closing the remaining handles releases references, allowing the system to reclaim the object when it is no longer needed.

🔗 Related Topics (MCQs)