3 ms·
If you are running this on your laptop and want to save your battery then use this patch... http://pastebin.com/BxXDDtTh http://pastebin.com/BxXDDtTh
by tankenmate 13y ago
If you are running this on your laptop and want to save your battery then use this patch...
http://pastebin.com/BxXDDtTh http://pastebin.com/BxXDDtTh
- akkartik 13y agoInteresting. How does the processor restart after hlt?
- tankenmate 13y agoAny interrupt will take the processor out of hlt state; i.e. hit a key on the keyboard, it will fire an interrupt and the processor will start processing again. The clock tick will also fire an interrupt. Once it fires an interrupt it will start searching for runnable processes again; e.g. a process can now return from a read() from it's STDIN tty now that you have typed a key.
- swetland 13y agoThere's some inefficiency here in that wake() doesn't cause the other cpu to wake immediately from hlt so it'll remain halted until the next timer tick or whatnot. It'd be fun to add some scheduler stats and poke around with things a bit. Some really trivial cprintf() tracing in scheduler() implies that single processes can ping-pong between CPUs, but the printing itself is slow and invasive and could possibly be the cause.
- swetland 13y agoNice catch. Actually speeds everything up a bunch. I did it a bit more tersely with: if (p == &ptable.proc[NPROC]) hlt(); after the sti() and initializing p to 0;
- userbinator 13y agoI remember in the pre-Pentium II days people cared rather little about power consumption (TDPs were only a few watts or maybe a dozen at most), and the idle process was basically a very tight infinite loop. Around the time of the PII people (especially overclockers) started noticing that the CPU would stay cooler when halted, and thus started a little industry of "CPU cooling software"... there's an interesting historical page on that here: http://estu.nit.ac.jp/~e982457/other/cpuidle/idle.htm http://estu.nit.ac.jp/~e982457/other/cpuidle/idle.htm A modern processor, on the other hand, takes a few watts halted and a hundred or more when active, and transitions between these states many many times per second. How much things have changed...