Live data from Hacker News

How to programmatically find out if computer is on

haiku-os.org

71–80 of 197 posts

Re: How to programmatically find out if computer is on

#72

While it is clearly a joke, it has a legitimate use as a syscall that does nothing so can be used to test the syscall process itself [1]. (Its cousin `is_computer_on_fire` is not a syscall.) [1] https://github.com/haiku/haiku/commit/ccaac177f64038c160de6f...

Sure.

Of course, one important trick here is that no matter how fast your system call is, not making a system call is just faster. io_uring is an example, as are futexes. So it's worth spending more effort on figuring out tricks to avoid doing the system call than exploiting tricks to shave a cycle or two off the time taken to execute one.

Re: How to programmatically find out if computer is on

#73
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."

Re: How to programmatically find out if computer is on

#75

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

Re: How to programmatically find out if computer is on

#76

While it is clearly a joke, it has a legitimate use as a syscall that does nothing so can be used to test the syscall process itself [1]. (Its cousin `is_computer_on_fire` is not a syscall.) [1] https://github.com/haiku/haiku/commit/ccaac177f64038c160de6f...

Sure. Of course, one important trick here is that no matter how fast your system call is, not making a system call is just faster. io_uring is an example, as are futexes. So it's worth spending more effort on figuring out tricks to avoid doing the system call than exploiting tricks to shave a cycle or two off the time taken to execute one.

Completely depends on your use case. If you're checking if sys calls work, you'd only need to run one first and see if it succeeds. Then you can be reasonably sure you have access to the rest.

And different programs have different speed requirements.

Re: How to programmatically find out if computer is on

#77

While it is clearly a joke, it has a legitimate use as a syscall that does nothing so can be used to test the syscall process itself [1]. (Its cousin `is_computer_on_fire` is not a syscall.) [1] https://github.com/haiku/haiku/commit/ccaac177f64038c160de6f...

I was thinking the same thing, although in reverse:

Imagine putting a few of these in as a joke and then you take it out and your parallelized code doesn't work anymore.

Not sure how all that's handled on Haiku specifically.

Re: How to programmatically find out if computer is on

#79
post #77

While it is clearly a joke, it has a legitimate use as a syscall that does nothing so can be used to test the syscall process itself [1]. (Its cousin `is_computer_on_fire` is not a syscall.) [1] https://github.com/haiku/haiku/commit/ccaac177f64038c160de6f...

I was thinking the same thing, although in reverse: Imagine putting a few of these in as a joke and then you take it out and your parallelized code doesn't work anymore. Not sure how all that's handled on Haiku specifically.

https://xkcd.com/1172/
Post reply on HN