10.3: Reclaim CPU cycles lost via fast user switching

Jan 06, '04 08:46:00AM

Contributed by: Han Solo

Recently, I discovered that my iBook had its CPU pegged even though I was only using Safari and a few other small apps. Turns out another user left Microsoft Word running in her account (via fast user switching), and that was eating some 70% of the CPU cycles. I didn't want to kill her process or forcefully log her out (as discussed in this hint), as I didn't know if she had any unsaved documents. But another recent hint gave me the idea of how to "pause" her processes and thereby reduce the CPU utilization. (Note: You will need to have administrative privileges in order to use this hint.)

First, you need to find the PID (process ID #) corresponding to the applications you want to "pause." This could be done by showing "Other User Processes" with Activity Monitor (in the Utilities folder), or in the Terminal with top or ps -U username. Then, launch Terminal.app and type:

sudo kill -STOP 1234
where 1234 is replaced with the process ID you found above. Another check with top or the Activity Monitor should confirm that 0.0% of the CPU is being used -- the application is "paused!"

To "resume" the application, type:

sudo kill -CONT 1234
It is really important to remember to "resume" the application before the other user switches back to their account: if you don't, they will see the spinning beach ball and the "Application Not Responding" message (when control-clicking on the "paused" application's dock icon). If they are not UNIX savvy (or have been locked out of the Terminal), they will have no recourse but to Force Quit their program and lose all their unsaved changes (which, of course, would defeat the purpose of this hint in the first place!).

I'm sure that someone more script-savvy could find a way to bundle this all up into a nice little app (giving credit, of course... ;) ). Or perhaps Apple will add a "Pause" option to the "Quit" and "Inspect" options under the "Process" menu of the Activity Monitor in a forth-coming 10.3.x.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20031216123111906