Newsgroups: comp.os.linux.hardware Date: 1996/06/08
: I remember once reading that Linux will do/not do a certain instruction that : pretty much shuts down the processor when idle. This was in contrast to : Win95 that continues to cycle tthe processor. : In other words, after three hours of being idle, Linux kept the processor : cold to the touch, while Win95 has it hot to the touch. : Was this a simple instruction? One that might be implemented in a Win95 : screensaver?
When Linux has nothing to do it executes the HALT instruction which stops the CPU cold. It wakes up again on the next interrupt.
When Win95 has nothing to do it sits in a busy loop polling. If you were to put a HALT instruction in a Win95 application it would freeze the machine and you would have to push the reset button to get it back.
>: >When Linux has nothing to do it executes the HALT instruction which stops >: >the CPU cold. It wakes up again on the next interrupt. >: > >: >When Win95 has nothing to do it sits in a busy loop polling. If you were >: >: Any kernel hackers want to comment on just how this is able to work? I >: for one can't figure out how if you halt the CPU, how it can wake >: up again. How is Linux able to get away with this? > >As far as i know the cpu wakes up when it recieves an interupt. On the >PC this happens at least as often as every timmer tick.
That is correct. The HLT stops the processor cold until an enabled interrupt (or NMI) or RESET signal is received.
Garrett P. Nievin
> > When Linux has nothing to do it executes the HALT instruction which stops > > the CPU cold. It wakes up again on the next interrupt.
True. HLT puts newer processors into the auto halt power down state, where they need only 15% of the power. The HLT state is left on any interrupt. Because there are at least timer ticks, the CPU doesn't freeze completely.
If you disable interrupts and even NMIs (via the CMOS port), and then do a HLT, then your machine will not wake up again until an INIT or RESET, asserted to the processor pins.
> > When Win95 has nothing to do it sits in a busy loop polling.
Unfortunately. But there is a program called POWER.EXE coming with MS-DOS, which also has this HLT stuff to save power. Maybe installing APM functions in Windows also installs such a HLT task. I don't know from head.
> Any kernel hackers want to comment on just how this is able to work? I > for one can't figure out how if you halt the CPU, how it can wake > up again. How is Linux able to get away with this?
Because of the timer ticks, which cause interrupts.
> Is the halt sort of like a "soft reboot" where the kernel is set up > to intercept the starting address or something? (The intel procs > are set to jump to ffff:fff0 or some such when the system first > boots, IIRC.)
No. The auto halt power down state is not a seperate operation mode. It just disables all unused parts in the CPU, which anyway is stopped by the HLT. Why waste energy, while the processor anyway waits due to the HLT?
> IMHO this would be something nifty on the kernel hackers' guide page > or what have you :).
There is nothing secret about the HLT. All this behaviour is described in full detail in the iPentium manuals.
Christian Ludloff
> I can set suspend mode in the BIOS to thirty minutes, but then when the > processor goes into standby, the clock stops. Makes sense but is a > terrible side effect. This is in both Win95 and Linux. Would it be a > BIOS function to allow the clock timer to continue?
To be correct, the kernel's internal clock stops. However, the bios clock (aka hardware clock or CMOS clock) does not so all you need is to update the kernel clock from bios after resume. This is done automatically if you enable the apm_bios in linux (available since 1.3.37 or so), assuming that your bios implements apm (if it doesn't you'd still be able to set the clock, see clock(8), but you wouldn't get notified about resume events so you'd have to do some kind of polling). I don't have the faintest idea about Win95 but then I'm not answering to the Win95 newsgroup either ;).
Gabor J.Toth