0
0
Operating Systemsknowledge~20 mins

Thread pools in Operating Systems - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Thread Pool Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main advantage of using a thread pool?

Thread pools are used in many systems to manage multiple tasks efficiently. What is the primary benefit of using a thread pool instead of creating a new thread for each task?

AIt reduces the overhead of creating and destroying threads repeatedly.
BIt guarantees that tasks will run in the order they are received.
CIt allows threads to run without any synchronization mechanisms.
DIt ensures that only one task runs at a time.
Attempts:
2 left
💡 Hint

Think about what happens when threads are created and destroyed frequently.

📋 Factual
intermediate
2:00remaining
How does a thread pool manage tasks when all threads are busy?

In a thread pool, what happens to new tasks when all threads are currently executing other tasks?

ANew tasks are rejected and lost.
BNew tasks are placed in a queue to wait until a thread becomes free.
CNew threads are created immediately to handle the tasks.
DThe system pauses all running threads to make room for new tasks.
Attempts:
2 left
💡 Hint

Consider how a thread pool controls the number of active threads.

🔍 Analysis
advanced
2:00remaining
Identify the problem caused by an unbounded task queue in a thread pool

What issue can arise if a thread pool uses an unbounded queue to hold waiting tasks?

AThe system may run out of memory due to too many queued tasks.
BTasks will be executed out of order.
CThreads will be created beyond the pool size limit.
DTasks will be rejected immediately when the queue is full.
Attempts:
2 left
💡 Hint

Think about what happens if tasks keep arriving faster than they can be processed.

Comparison
advanced
2:00remaining
Difference between fixed-size and cached thread pools

Which statement correctly describes the difference between a fixed-size thread pool and a cached thread pool?

ACached pools reject tasks when all threads are busy; fixed-size pools queue tasks indefinitely.
BFixed-size pools create threads on demand; cached pools have a fixed number of threads.
CFixed-size pools have a set number of threads; cached pools create new threads as needed and reuse idle ones.
DBoth pools create unlimited threads but differ in task queue size.
Attempts:
2 left
💡 Hint

Consider how each pool manages thread creation and reuse.

Reasoning
expert
3:00remaining
Why might a thread pool cause deadlocks in certain applications?

Consider an application using a thread pool where tasks submit other tasks to the same pool and wait for their completion. Why can this design cause deadlocks?

ABecause the thread pool automatically cancels tasks that wait for others.
BBecause thread pools do not support nested task submission.
CBecause tasks submitted later always have lower priority and never run.
DBecause all threads may be blocked waiting for subtasks, no thread is free to run those subtasks.
Attempts:
2 left
💡 Hint

Think about what happens if threads are waiting for other threads that cannot start.