Live data from Hacker News

How to programmatically find out if computer is on

haiku-os.org

131–140 of 197 posts

Re: How to programmatically find out if computer is on

#131

Why would is_computer_on_fire() return a double and not true/false? Even for a joke function, this seems like bad practice. If the function is named is_state(), I expect a boolean return. > Returns the temperature of the motherboard if the computer is currently on fire. Smoldering doesn't count. If the computer isn't on fire, the function returns some other value.

Maybe it’s a probability function. Something like “hey there’s a .7 percent chance your computer is engulfed in flames”

Re: How to programmatically find out if computer is on

#132

Why would is_computer_on_fire() return a double and not true/false? Even for a joke function, this seems like bad practice. If the function is named is_state(), I expect a boolean return. > Returns the temperature of the motherboard if the computer is currently on fire. Smoldering doesn't count. If the computer isn't on fire, the function returns some other value.

Wonder if this is a throwback to the HCF command.

https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing...

Re: How to programmatically find out if computer is on

#133

I'm curious if there's any significance in number 0.63739 in this implementation double is_computer_on_fire(void) { return 0.63739; } https://github.com/haiku/haiku/blob/8f16317a5b6db5c672f33181...

When you convert float->hex->int->unix time, you get Sun Jul 27 2003 01:33:50 GMT+0000, which kind or corresponds to when the function might gave been implemented in Haiku. But if it matches BeOS R5, then the number may have another significance.

Re: How to programmatically find out if computer is on

#134
post #29

Earlier quoted context omitted.

Nah. Just bump that responsibility to the caller, and power supply manufacturer. Have the caller call power_on_computer() first always. This will ensure you always get defined state! ...What do you mean not every power supply manufacturer implements the power_on_computer() function as a NOOP if the computer is already on?!

I know that at least Solaris implemented SIGPWR signal to inform programs of a power failure: https://community.bmc.com/s/article/Inquira-KA334556

TIL: linux also implements SIGPWR. Using "kill -PWR `pidof dd`" killed it with "power failure".

Re: How to programmatically find out if computer is on

#135

Earlier quoted context omitted.

I've often wondered why WOL is so poorly designed. WOL should be a function of the NIC, completely independent of the OS and capable of returning status codes even if the computer is "off".

Is... this not how your WoL works? Hitting the NIC is equivalent to pressing the on button, boots the OS, etc. I've been using this for years to wake hosts at home when I'm abroad. It's invaluable.

I think the parent means that you should be able to talk to the NIC about the computer, without the NIC needing to get the CPU powered on so that the CPU can tell the NIC what to do. Like a very-minimally-functional BMC.

Re: How to programmatically find out if computer is on

#136

Earlier quoted context omitted.

I've often wondered why WOL is so poorly designed. WOL should be a function of the NIC, completely independent of the OS and capable of returning status codes even if the computer is "off".

Is... this not how your WoL works? Hitting the NIC is equivalent to pressing the on button, boots the OS, etc. I've been using this for years to wake hosts at home when I'm abroad. It's invaluable.

For the sake of the argument, I think it's more of a shared capability of the motherboard _and_ the NIC, rather than the sole responsibility of the NIC.

I wonder if that could be implemented solely by the motherboard. After all, it could supply a small amount of power to the NIC while shutdown and embed a minimal NIC driver to monitor incoming packets without the need for the NIC to do the monitoring itself.

Re: How to programmatically find out if computer is on

#137
I was hoping this would be implemented by actually reading a memory location that was set to 0, when the system is hibernating/sleeping. But it always returns 1. If it was reading a flag from memory it would be useful when examining memory dumps.

https://github.com/haiku/haiku/blob/8f16317a5b6db5c672f33181...

Re: How to programmatically find out if computer is on

#139

> is_computer_on() How does this relate to computer being in Halt state, which is quite valid state for servers (there could be even a dedicated Halt button)? Technically computer hardware is ON. I remember that in such state it shows a "carrot" prompt (>>>) from the SRE console. By the way, there is also HCF instruction (Halt and Catch Fire). https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing...

I’ve wondered what Go APIs involving channels should do when the computer is put to sleep and later on wakes up.

Maybe I haven't done enough Go to know why that's something to wonder about? They wouldn't just carry on when resumed like anything else?

Re: How to programmatically find out if computer is on

#140
post #135

Earlier quoted context omitted.

Is... this not how your WoL works? Hitting the NIC is equivalent to pressing the on button, boots the OS, etc. I've been using this for years to wake hosts at home when I'm abroad. It's invaluable.

I think the parent means that you should be able to talk to the NIC about the computer, without the NIC needing to get the CPU powered on so that the CPU can tell the NIC what to do. Like a very-minimally-functional BMC.

Intel vPro?
Post reply on HN