CurrentProcessorSpeed does not work

Discussion in 'Mac Programming' started by anandds, May 8, 2009.

  1. anandds macrumors newbie

    May 8, 2009

    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());

    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?

  2. gnasher729 macrumors P6


    Nov 25, 2005
    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.
  3. anandds thread starter macrumors newbie

    May 8, 2009
    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?
  4. Some Guy 555 macrumors regular

    May 26, 2009
    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.
  5. autorelease macrumors regular

    Oct 13, 2008
    Achewood, CA
    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.

Share This Page