Difficulty |
4 |
Reading material |
Create a task scheduler that is parameterized in the number of threads to use.
Let’s call this parameter thread_count
.
The scheduler should create thread_count
threads.
Each thread should follow the same simple algorithm:
while unclaimed_tasks:
task = claim task
task.perform()
The difficulty lies in the fact that the worker threads have shared state, which needs to be synchronized. This means that if threads read/write to the same variable, special precautions have to be taken.
Implement the task scheduler described above. Make it available through a factory function
|
1. Evaluation
|