logoalt Hacker News

marcosdumayyesterday at 5:16 PM2 repliesview on HN

I don't understand your problem. Did you expect your C++ program to get uninterrupted access to the computer? What progression do you think isn't happening there?

I think you are misinterpreting that. That phrase unambiguously says the loop is preserved on the final binary.


Replies

JoshTriplettyesterday at 5:19 PM

I expect an infinite loop to be compiled into, for instance, a jump instruction jumping to itself. The OS, if there is any, is welcome to interrupt and context switch. I don't expect code that has no function calls at all to have a system call inserted into it.

show 2 replies
rcxdudetoday at 12:29 AM

Any program in an OS only gets as much resources allocated to it as the OS allows (OK, in any general-purpose OS written in the past few decades). sched_yield() doesn't actually reduce that allocation in most cases, anyhow: in fact it has a higher chance of increasing the resources that the thread uses spinning in a loop because it's gonna be thrashing the scheduler as well.