Page 1 of 1
problem with freezing computer
Posted: Tue Aug 19, 2003 3:29 pm
by beyondsociety
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:
If I comment it out, I still get the delay followed by the reboot. Before it used to just freeze, what could be the problem?
Re:problem with freezing computer
Posted: Tue Aug 19, 2003 4:12 pm
by Tim
This will only freeze the computer if interrupts are disabled. To do a full freeze, either:
or:
CLI followed by HLT effectively turns the CPU off.
Re:problem with freezing computer
Posted: Tue Aug 19, 2003 5:50 pm
by tuxaroo
This may be off topic, but how come some OSes I have to shutdown by hand? Like Linux just stops there.
Re:problem with freezing computer
Posted: Tue Aug 19, 2003 5:55 pm
by Tim
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.
Re:problem with freezing computer
Posted: Wed Aug 20, 2003 2:53 am
by Curufir
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.
Re:problem with freezing computer
Posted: Wed Aug 20, 2003 11:26 am
by beyondsociety
Trying what tim suggested didn't help. I wonder if there is something wrong with my cli and hlt functions?
Code: Select all
void cli()
{
__asm__ __volatile__("cli");
}
void hlt()
{
__asm__ __volatile__("hlt");
}
Re:problem with freezing computer
Posted: Wed Aug 20, 2003 5:02 pm
by Tim
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.
Re:problem with freezing computer
Posted: Tue Aug 26, 2003 9:46 am
by beyondsociety
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.