Live data from Hacker News

How to programmatically find out if computer is on

haiku-os.org

91–100 of 197 posts

Re: How to programmatically find out if computer is on

#92

> 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...

Wouldn't a CPU halt state mean no code is running?

A CPU can halt as a power saving measure, and still respond to interrupts.

Re: How to programmatically find out if computer is on

#94

Presumably there's a non-joke version of this at some level in the hardware / firmware stack?

https://docs.microsoft.com/en-us/windows/win32/power/system-...

I read "Soft Off" as "sort of" and though, well, that's probably the best answer one can get in certain situations.

Re: How to programmatically find out if computer is on

#95
post #89

While this is a joke, there are some contexts in which it does make sense to ask whether the computer is on. For instance, most laptops have an embedded controller which runs all the time, even when the laptop is powered off, and manages things like battery charging and the power state. Within that embedded controller, an is_computer_on() function could legitimately return "false".

Yeah, would make sense in that case. Probably would name the function differently though, to indicate the difference. "is_computer_on" makes me think it's checking the state of the computer this code is running on, not the state of another computer than "myself".

Re: How to programmatically find out if computer is on

#96

Earlier quoted context omitted.

Wouldn't a CPU halt state mean no code is running?

a computer has multiple CPUs. One may be halted while another still running.

If the function call doesn't allow you to specify a CPU core, then it seems like it would be testing either the logical or'ing of all core's powered-on state, or the state of the current core.

In order for the code to execute anywhere, at least one core must be powered on and not halted. Also, I would consider a halted CPU to still be powered on.

Otherwise, the function's name has no relation to it's behavior and it's a buggy function on top of being a useless but amusing thought experiment.

Re: How to programmatically find out if computer is on

#97

I was working on an embedded system. I told the hardware guy that the CPU clock input wasn't running. He said, "Any reasonably intelligent software should have detected that condition and handled it." I replied, "Seems to me the software acted appropriately for the conditions."

I tried inverting the clock and running a one way hash and my CPU vanished...

Re: How to programmatically find out if computer is on

#98
post #64

Earlier quoted context omitted.

Interesting, but I think parent was asking how to run it on silicon.

now i'm confused.

"On metal" would refer to running the OS without any additional layers like virtualization, in this context.

But it could also refer to the material "metal" (or the collection name for bunch of materials really), whereas computers are commonly known for being made with a lot of silicon instead of metal.

Hopefully I didn't dissect too much of the frog to kill it.

Re: How to programmatically find out if computer is on

#99

Earlier quoted context omitted.

Wouldn't a CPU halt state mean no code is running?

a computer has multiple CPUs. One may be halted while another still running.

which implies that the power state of the whole core cluster is on, so the syscall is defined to return 1
Post reply on HN