🎓 BookMCQ
← Back to 19. Windows 7

📝 Thread pool in Process management in Window 7 (6 MCQs)

Reusing Worker Threads Through a Thread Pool

A Windows 7 thread pool is a mechanism for executing work items using a managed collection of reusable worker threads. Instead of creating a new thread for every task, an application queues work to the pool, which schedules it on available workers. Thread pool facilities also support timers, asynchronous callbacks, and I/O completion-related work.

Why Repeated Thread Creation Is Expensive

Creating and destroying threads consumes memory, kernel objects, and processor time. Applications with many short tasks may spend unnecessary effort managing thread lifetimes. A thread pool amortises this cost by reusing workers and adapting concurrency to the available workload and system resources.

Queuing Work and Worker Dispatch

An application submits a callback or work item to the pool. The pool queues the request and assigns it to an available worker thread when appropriate. When a worker completes its task, it can process additional queued work instead of terminating, while pool management adjusts concurrency according to activity.

Example of Processing Multiple File Tasks

An application must calculate checksums for 100 files. Rather than creating 100 threads, it queues 100 work items to a thread pool. A smaller set of workers processes files concurrently, reusing each thread for multiple tasks and reducing thread management overhead.

Throughput, Responsiveness and Blocking Risks

Thread pools reduce repeated thread creation and can improve throughput for many short tasks. However, too many blocking tasks may occupy all workers and delay queued work. Applications should avoid long waits inside pool callbacks and should manage shared data with suitable synchronisation.

Misconceptions About Windows Thread Pools

'A thread pool creates one thread for every work item' ignores worker reuse. 'Thread pool workers always run simultaneously' overlooks available processors and concurrency limits. 'A pool automatically prevents race conditions' is false because callbacks may still access shared data concurrently.

Exam Focus: Work Queues and Worker Reuse

Explain how work items are queued and assigned to reusable workers. Compare pool-based execution with creating a dedicated thread for every task. Questions may examine resource overhead, blocking callbacks, concurrency limits, and why shared data still requires synchronisation.

Key Terms of Windows Thread Pools

  • Thread pool - Collection of reusable worker threads.
  • Work item - Task submitted to a pool.
  • Worker thread - Thread executing queued tasks.
  • Callback - Function invoked for a work item.
  • Concurrency - Number of tasks executing together.
1
Easy
3
Medium
2
Hard

📝 All Thread pool in Process management in Window 7 MCQs

Q1. A driver’s ISR queues a work item to the system’s thread pool. Which of the following best describes why using a thread‑pool worker thread is preferred over creating a new thread for each work item?

A.It guarantees the work runs at the highest interrupt priority. ✅
B.It reduces overhead by reusing existing threads and avoids excessive context switches.
C.It allows the work to execute in user mode without kernel mediation.
D.It ensures the work item runs only when the CPU is idle.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Using a thread‑pool worker thread reuses already‑created threads, so the system avoids the cost of allocating stack space, initializing thread structures, and performing a full context switch for each work item. This cuts CPU time and memory pressure, directly improving responsiveness. Option A is wrong because thread‑pool threads run at normal thread priority, not the highest interrupt priority. Option C misstates that the work runs in user mode without kernel involvement, which is not true for kernel‑queued work. Option D is incorrect because the work can run while the CPU is busy, not only when idle.

Q2. How does the priority relationship between Deferred Procedure Calls (DPCs) and thread‑pool work items affect the latency of I/O completion notifications?

A.DPCs run at a lower priority than thread‑pool work items, increasing latency. ✅
B.DPCs run at a higher priority, so they pre‑empt thread‑pool work items, reducing latency.
C.Both run at the same priority, so latency is unaffected.
D.Thread‑pool work items always run before DPCs, eliminating latency.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: DPCs are scheduled at a priority that is higher than normal threads but lower than most interrupt service routines. Thread‑pool work items are scheduled as normal threads, so when a DPC is pending, it will execute before any thread‑pool work, potentially delaying the work that signals I/O completion. This ordering means the latency of the notification depends on the DPC workload. Option A reverses the priority order, option B incorrectly claims DPCs pre‑empt thread‑pool work, and option D suggests thread‑pool work always runs first, which is not the case.

Q3. A server application experiences high CPU usage because each incoming network packet triggers an APC that creates a new thread. Which modification would most effectively improve performance?

A.Replace the APC‑generated threads with work items queued to the thread pool.
B.Increase the priority of the newly created threads. ✅
C.Disable APCs and handle packets synchronously in the ISR.
D.Limit the number of network packets processed per second.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Queuing the work to the thread pool reuses existing threads, eliminating the overhead of constantly creating and destroying threads for each packet. This reduces context‑switch costs and memory fragmentation, leading to lower CPU usage. Raising thread priority (option B) would not address the creation overhead and could worsen overall scheduling. Disabling APCs (option C) would force the ISR to do more work, increasing interrupt latency. Limiting packet processing (option D) merely reduces throughput without improving the underlying inefficiency.

Q4. What does APC stand for in the Windows kernel?

A.Asynchronous Procedure Call ✅
B.Advanced Process Control
C.Application Process Component
D.Atomic Procedure Completion
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The abbreviation APC in the Windows kernel expands to Asynchronous Procedure Call. This mechanism allows code to be executed in the context of a specific thread when that thread enters an alertable wait state. The other options are incorrect: Advanced Process Control is unrelated to Windows kernel internals, Application Process Component is not a defined term, and Atomic Procedure Completion does not describe the asynchronous nature of APCs.

Q5. A multimedia application queues 200 short‑duration tasks to the thread pool, but the default pool size is only 8 threads. Which strategy will most likely keep frame rendering smooth while still processing all tasks?

A.Manually create additional threads equal to the number of tasks.
B.Increase the thread‑pool minimum size to 50 threads. ✅
C.Use a bounded queue that limits tasks to the current pool size and process excess tasks on the calling thread.
D.Leave the pool unchanged and accept occasional frame drops.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Increasing the pool’s minimum size to 50 threads (option B) would create many more threads than the CPU can efficiently handle, leading to excessive context switches and cache thrashing, which harms real‑time rendering. Manually creating 200 threads (option A) is even worse. Using a bounded queue that forces excess tasks onto the calling thread (option C) can block the rendering thread, causing jitter. Allowing the pool to stay at its default size while the calling thread processes overflow tasks (option D) balances concurrency and ensures the rendering thread remains responsive, preserving smooth frame rates.

Q6. Why are Deferred Procedure Calls (DPCs) restricted from performing operations that may cause page faults?

A.Because page faults can raise the interrupt priority above DPC level. ✅
B.Because a page fault would require the DPC to run at user‑mode privilege.
C.Because handling a page fault could block the CPU, defeating the purpose of low‑latency DPC execution.
D.Because page faults are only allowed in ISR context.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: DPCs are intended to finish quickly after an ISR has deferred non‑urgent work. If a DPC caused a page fault, the system would need to schedule a page‑in operation, potentially blocking the CPU for an indeterminate time and increasing latency, which contradicts the design goal of rapid DPC completion. Option A misstates the priority relationship; page faults do not raise interrupt priority. Option B incorrectly claims DPCs would run in user mode. Option D suggests page faults belong to ISR, which is also false.

🔗 Related Topics (MCQs)