Hacker News new | ask | show | jobs
by jesperwe 29 days ago
I wonder how they implement is_computer_on() under Linux?

(https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_Sys...)

2 comments

In the simplest way. More interesting is the result for is_computer_on_fire()

https://github.com/VitruvianOS/Vitruvian/blob/0e4c6e33ab235b...

Why does it return a double?
I was wondering about the significance of the returned value 0.63739. Best explanation I found was this HN post [0]: "Referencing a US telephone keypad, it spells NERDY"

https://news.ycombinator.com/item?id=29292424

Per the BeBook:

> Returns the temperature of the motherboard if the computer is currently on fire.

Test the API kernel calling convention when dealing with 64 bit IEE754 doubles on a 32 bit CPU, especially when dealing with MSB vs LSB processors.

Also, a long time ago (pre 486DX), processors did not have FPU circuitry instead it was a FPU coprocessor. When dealing with a kernel context switch, you'd have to copy all registers to a stack. With a coprocessor, you'd have to make sure those registers got copied as well. Which was slower with coprocessors ... So for a time some real time kernels did not allow context switching of FPU. To support that, you'd get the performance hit.

These days its all integrated so you dont have to worry about it ...

Cheating. Not involving the kernel at all.
on fire

> The following functions, types, and structures are used to convey basic information about the system, such as the number of CPUs, when the kernel was built, what time it is now and whether your computer is on fire.

That’s sometimes a handy diagnostic if it’s a remote, headless system.