Comment by usr1106
5 days ago
This text repeats things that I have read many times before, maybe because it's heavily AI assisted as other have suspected. But it fails to answer my questions I have had unanswered for years.
Q1: Let's start with a single core machine. The explanations always say: The scheduler does this and does that. As if the the scheduler would be some external entity. In the single core machine there is only one actor. The core that executes instructions. One after another. Where the next one is either determined by the program counter or an interrupt. I would really like a text that never changes perspective. It's the CPU that does things (sometimes it executes code belonging to the scheduler). It's never the scheduler that sits there in an outside supervising position and can do things.
So lets take this pure user space while(1) task. The CPU jumps into the timer interrupt code. The article says a flag will be set, but the real preemption will happen later at a safe spot. So what code is executed after the flag has been set? Where and how will it notice that now we are at a safe spot to preempt?
Q2: The multi-core case. All texts write about "the scheduler". As if we had n cores and 1 scheduler that supervises what they are doing. But that's certainly not what is happening. I guess all cores execute some scheduler code regularly (except the tickless ones, but that's yet another story and rare on a "typical" machine). But how does that work without creating a mess in the data structures? Well, some synchronization primitives are probably needed. But how does that scale for dozens and 100s of cores? I guess most structures are local to a core and the global ones are modified rarely?
Where are these 2 questions answered?
No comments yet
Contribute on Hacker News ↗