Understanding task scheduling in single-threaded Tokio with busy listeners
This is a hard Rust question that tests deep knowledge of async runtime behavior, specifically how Tokio's executor schedules tasks on a single thread when some tasks are in tight loops. The question probes whether you understand the difference between fairness in task scheduling and the mechanics of when control actually transfers between tasks.
To reason through this, you need to understand how Tokio's work-stealing scheduler operates, what happens when a task never yields the thread, and the role of await points in enabling preemption. The answer hinges on recognizing that a task continuously receiving Poll::Ready may never suspend—and what that means for other spawned tasks in a single-threaded runtime.
- Task scheduling and fairness in async executors
- The relationship between
Poll::Ready, Poll::Pending, and yields
- Single-threaded vs. multi-threaded Tokio runtime behavior
- Busy-waiting and resource starvation in async code