Q: can you describe a blocking scenario in a CPU-bound system?
Think of a few CPU bound systems like
- database server
- O(N!) algo
- MC simulation engine
- stress testing
I tend to think that a thread submitting a heavy task is usually the same thread that processes the task. (Such a thread doesn’t block!)
However, in a task-queue producer/consumer architecture, the submitter thread enqueues the task and can do other things or return to the thread pool.
A workhorse thread picks up the task from queue and spends hours to complete it.
Now, I present a trivial blocking scenario in a CPU bound system —
- Any of these threads can briefly block in I/O if it has big data to send. Still, system is CPU-bound.
- Any of these threads can block on a mutex or condVar