Understanding Thread Blocking and Scheduling in Operating Systems
The article explains what thread blocking means in operating systems, how the OS moves blocked threads to wait queues and schedules other threads, discusses spin locks, and reflects on common misconceptions and community debates about callbacks versus polling.
Hello, I'm Xuan Yuan. Due to the pandemic I stayed in Chengdu during the National Day holiday and decided to read and share technical content.
While browsing Zhihu, I encountered a question about the true meaning of "blocking". I realized that many people, including myself when first learning operating systems, mistakenly think a blocked thread simply loops waiting.
In reality, blocking occurs when the operating system moves a thread into a waiting queue, allowing the scheduler to run other threads; the thread is resumed once its waiting condition (e.g., I/O, lock, condition variable, signal) is satisfied, at which point it is placed back into the ready queue.
The article also touches on spin locks, noting that they continuously spin and can waste CPU resources if used imprudently, contrasting them with ordinary locks that block without busy-waiting.
I recommend a friend’s extensive OS series, which builds a Linux‑kernel‑based operating system from scratch and has gained significant community attention (14K GitHub stars) and even a book deal.
Returning to the Zhihu discussion, most answers emphasize that thread blocking is not polling, but a comment sparked a debate about whether callbacks merely shift polling to a cheaper stage, prompting a broader conversation about the nature of interrupts and asynchronous handling.
The piece invites readers to share their perspectives on these concepts.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.