Luke Mazzeri <etyrnal at ameritech.net> writes: > i wonder if it would be possible to write code into the kernel that > would allow 'real time' 'hot swapping' of the cpu ... i mean that > while your machine is booted and operating, would it be possible to put > ONE processor into deep sleep or turn it off? and reactivate it when > needed? > > the machine could (if technologically possible) run on one proc. until > the primary proc. hit 100% then the 2nd proc. could kick in or 'wake > up'... WARNING: The following text is very geekified. Persons who do not have at least mildly geeky inclinations beware; your brain may want to pack up shop and leave if you attempt to read the following message... Well, I'm currently in school learning all about this sort of thing, and as far as I know, it should be quite easily done, and is possibly done already (though I don't know any examples). The problem though is that running 1 processor at 100% doesn't give you as good performance as two at 50%. Here's a quick rundown of how multitasking works (in terms of running multiple applications at once, not multiple CPUs): Any given processor (with the exception of a few brand new designs that try to get around this) can only execute code from one program at a time. This is partly because each program needs registers (instantly-available temporary data storage) to store variables, and those registers can be used by any program; so to run a different program, you have to save all those registers to somewhere (like RAM) and then let the next program run for a while. Then you have to determine how to split up the CPU time while running multiple programs: OS 9 used cooperative multitasking, meaning that when a program was ready to relinquish control, it would tell the OS it was done for a while, and the OS would start running the next program. If a program wants to monopolize the CPU, it can certainly do this; everything else slows down, but it's how games and Virtual PC and other things can give themselves an extra kick. OS X uses preemptive multitasking. In this scheme, each process gets a fixed block of time to run, and then the OS stops it and runs the next program. Programs can return before their time is up if they have nothing to do. If you toss in a second processor in OS X, programs can get time on either processor as they need it, so the programs still get the same block of time when they run, they just get time twice as frequently. Anyway, if you run one processor at 100% before kicking in the second one, you get a fairly large latency between a program needing to do something and having the available resources to run it. It would be better (though I'm not sure if it would be noticeable or not; but it would depend on what you're running) to run two processors at 50%. IMNSHO, the best option (if you can cram two CPUs into something so that they don't use too much battery power) would be to have the second processor configurable in Energy Saver for battery versus AC settings: Allow the user turn one processor off, and additionally turn processor cycling on or reduce the clock speed on however many CPUs the user wants to be running. An interesting thing: in OS X, you can actually have one processor kernel panic while the other continues normal operation. The computer won't be able to actually handle doing anything, but the CPU is not panicked. Along these same lines, I was once repairing a dual 1-GHz PowerMac (I work in an Apple Authorized repair shop), and got a computer where the CPUs were running too hot and/or not being cooled fast enough. After running for about 5 minutes, the computer would panic, and then it would panic AGAIN. One CPU would panic first after hitting the highest temperature it could handle, then the other CPU would do the same. That was the only time I've ever seen a double kernel panic. In a kernel panic, you can even see which processor is panicking; it tells you right at the beginning with either (cpu 0) or (cpu 1). Those of us with single processor machines (should) always see cpu 0. Kynan Shook kshook at mac.com http://homepage.mac.com/kshook/index.html