Nicholas Blachford <nicholas@xxxxxxxxxxxxxx> wrote: > Is this paper test not just a simulation of a powered up computer, It could be, but then the function would return 1 -- because it's an emulation of a powered-up machine (as opposed to an emulation of a hypothetical powered-down machine). > If a computer is powered down, then there's no electricity flowing > and therefore any return from any function call cannot be anything > other than 0, it cannot be a 1 since that requires energy and there > is none... Hmm, but supposing a theoretically perfect system, energy is only required to transition between logic states. Shouldn't it return its last value instead of zero in that case? Or perhaps this could be counteracted somehow by returning a balanced pair? (e.g. 0x01 when the computer is on, 0x80 when the computer is off) > Nitpicking aside, I suppose in these days of processors with > aggressive sleep modes and watchdog processors it's quite possible > for the CPU to be off while the computer is still on... True enough. It all depends what you define as the computer, and what you define as "off"... On some motherboards, the on-board microcontroller(s) remain powered even when the machine is off at the mains (powered from the battery on the motherboard), so this could possibly be exploited to implement is_computer_on(): 1) User program is loaded. Symbols are checked to see if the program references is_computer_on(). If it doesn't, the program runs as normal for efficiency. Otherwise the steps below take effect. 2) The user program is uploaded to a microcontroller on the motherboard, where an x86 emulator executes the program. 3) If the user program calls any OS functions or accesses any shared memory, the power status of the system is checked. If it's powered-up, the main CPU is interrupted, and the call is handled on the main CPU. Otherwise it's emulated on the microcontroller (probably just stubbed-out to always return a failure code -- because without power, there's no disk, network or I/O anyway). 4) A timeout is implemented on the microcontroller, and if the x86 CPU does not complete the OS call (due to power being lost or the OS crashing), the microcontroller emulates the OS call, and all subsequent OS calls are handled through emulation as well. 5) If the user program calls is_computer_on(), the microcontroller simply checks the power status and returns the correct code. 6) In the event of the user program being highly bloated and not fitting in the RAM capacity of the microcontroller (~64 bytes), disk paging could be implemented through the OS call mechanism. Of course any pages not locked into RAM may become inaccessible when the system is turned off, but that's understandable. 7) In the event of the motherboard not having a suitable microcontroller, or lacking any host communication facilities, the OS would need to report an error when the program is loaded. Is this cheating?