Fun_People Archive
11 Dec
Existential Operating Systems Philosophy


Content-Type: text/plain
Mime-Version: 1.0 (NeXT Mail 3.3 v118.2)
From: Peter Langston <psl>
Date: Fri, 11 Dec 98 11:53:39 -0800
To: Fun_People
Precedence: bulk
Subject: Existential Operating Systems Philosophy

X-Lib-of-Cong-ISSN: 1098-7649
Forwarded-by: Dag Xien <fredag@oien.net>

[Forwards wondering why Windows isn't as much fun as BeOS...]


DEVELOPERS' WORKSHOP: The Refrigerator Question
By Eric Shepherd sheppy@be.com
...

Of all the functions the BeOS provides to programmers, one of the least
understood and most widely debated is is_computer_on(). Documentation has
been sketchy, and developers have debated the best use for this function.
This week, we'll investigate is_computer_on() in depth.

Some developers claim that this function always returns 1, and say that it's
a sham. They say their tests have produced significant empirical evidence
to this effect. Others offer circumstantial evidence, such as "programs
can't run when the computer's off," which doesn't really explain anything.

This is a lot like trying to figure out if the light stays on in the
refrigerator when you close the door. How can you be sure that
is_computer_on() isn't returning some other value when the computer's off?
Let's look at a test program:

#include <OS.h>
#include <stdio.h>


int main(void) {
  int i;


  printf("#     Result\n");
  printf("----- ------\n");
  for (i=1;i<=25;i++) {
    printf("%-5d %ld\n", i, is computer on());
  }
  return 0;
}

If you run this program, you get the following output:

#     Result
----- ------
1   1
2   1
3   1
4   1
5   1
6   1
7   1
8   1
9   1
10   1
(and so on)

Now try running the program and shutting off your computer while it's
running. Unfortunately, printf() doesn't work reliably in this case; you
don't see your output, because the computer's video hardware becomes
unreliable when turned off. You might try customizing this code to write
the output to disk, but unfortunately, hard drives also become unreliable
when power isn't applied to them throughout their operation.  Networking
and serial ports likewise have a high failure rate when power is turned off.

In other words, the empirical evidence is a little flimsy. Due to failures
beyond Be's control, test programs such as the one above can't present their
full results. I'm not saying that is_computer_on() returns some other value
when the computer isn't running, but this is a prime example of the
difficulty encountered when testing a theory through code.

However, Be guarantees that is_computer_on() will always return 1 if the
computer is running.


prev [=] prev © 1998 Peter Langston []