Comment by yk
15 hours ago
I would expect an infinite loop
while(true) std::this_thread::yield();
to be designed to play nice with the scheduler, while I would assume a infinite loop
while(true);
to not play nice with the scheduler. Now, I can't really imagine where this matters except for horrible hacky attempts at faking a real time scheduler on windows, but breaking horrible hacky attempts at faking a real time scheduler sounds like the kind of bug you hear about in the evening news.
I would expect them to be the same or for the former to be worse. It's rarely useful to call sched_yield at all, but calling it repeatedly in a loop seems more likely to expose bad behavior in a scheduler than improve the interaction. Schedulers are already perfectly well designed to handle threads trying to take up 100% of the CPU: that's the default state for any CPU-bound task.
under what conditions would the infinite loop be scheduled over something else after it has run out of its time slice?