Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

anandds

macrumors newbie
Original poster
May 8, 2009
12
0
Hi,

I wrote a simple test progrm (as below) to check the output of the CurrentProcessorSpeed API when the system goes idle.

===============
int main()
{
while (1)
{

printf("speed %d\n", CurrentProcessorSpeed());
sleep(1);
}
}
==================

This prints the Current Procesor Speed every second. Even when the system goes idle (the I see the output the same as when the system is in normal conditions (2000). I was expecting this to return 1 when the system goes idle. Any ideas on this? Am I missing something here?

Thanks,
Anand
 
Power Manager is quite outdated. "Current processor speed" doesn't even make sense when you have multiple cores. In addition, while the call to the function "CurrentProcessorSpeed" is executing, the system is not idle. It may have been idle just before the call, and may be idle again just after the call, but not during the call. And I am not sure whether desktop machines change their processor speed at all or use other methods to save power.
 
Re: CurrentProcessorSpeed does not work

Thanks for the reply. Do you have any idea what could be done to detect if the system goes to idle state?
 
A few basic concepts must be mentioned here to explain why this is theoretically impossible. To start lets refer to programs as instructions that are sent to the cpu (which will then process those instructions and output results in many ways).

Now how would you be able to give an instruction that asked the cpu to tell you what its speed was, without it actually working on the instruction?

It cannot be done, at least not in any conventional way. If however you had a multi-cpu (NOT multicore) system, then its doable.
 
There's no such thing as a truly 100% "idle" state. The OS is always running some processes/daemons in the background, even when there are no applications running and no windows open.

A better measure of system activity is CPU usage, which can be obtained, among other ways I'm sure, through the Mach API.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.