Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
When I issue my "freeze the computer function" which uses a for loop, my computer delays for a while and then reboots instead of freezing. The for loop is as follows:
Shutdown by hand as opposed to what? Pulling the power cable out of the wall? You need to inform the OS that you're about to turn the computer off, to make sure any applications get a chance to save and exit, that any cached data is written to disk, and that the file system is left in a consistent state. Recent versions of Windows look for the power button being pressed (through ACPI) and will treat that as a shutdown request. Without ACPI, you have to ask the OS to shutdown before you can remove the power.
Think he means that some OS don't turn the computer off after shutdown (Eg Win98).
The answer is it depends which OS your running, which hardware you're running on and most especially if one of either ACPI or APM is supported by both OS and hardware. These functions are what is used to power down the computer, shutdown the monitor etc. If they aren't there, then the best the OS can do is put up a little message saying 'Turn me off now please' or similar.
Maybe the way you're calling them. CLI *always* turns off interrupts. HLT *always* halts the processor until the next interrupt is received. So CLI followed by HLT halts the processor forever.
After some testing, my problem is not with my cli or hlt functions but with my c function that adds interrupt handlers as it is tripple faulting my computer. I tested it in bochs and I get the same exception. I now have to figure out why this is happening.