Hacker News new | ask | show | jobs
by e3b0c 2809 days ago
Does it also imply that a non-blocking event loop in the userspace application is energy-inefficient?

Likewise, given that some OSes APIs (syscalls) provide both non-blocking and blocking modes, should we prefer the blocking ones concerning energy efficiency?

2 comments

They are pretty much equivalent. The kernel will only schedule your program when an event happens. The difference is that by using a blocking syscall you will need more threads which indirectly decreases energy efficiency through increased context switching and RAM usage. If you only have a single thread then blocking or non-blocking is going to consume the same amount of energy.
Yes. A blocking loop will allow the CPU to power down until an event arrives. A non-blocking/busy loop will continue to burn CPU cycles and the CPU will be busy and cannot reach lower power states.