Question

I am looking for a windows function, structure, API that control the multiplier of the bus speed of the processor. In other word, I am trying to adjust frequency of the CPU by varying the multiplier.Currently, I am adjusting the CPU speed by modifying the power scheme using the following function.

 PowerWriteDCValueIndex(…,…,…,…)

And adjust the

     THROTTLE_MAXIMUM; & THROTTLE_MINIMUM;

However, this allows me to vary the processor speed as % which is not accurate. Hope my question is clear and you can help.

Thanks.

Était-ce utile?

La solution

The handling of power states in the OS is handled by a kernel driver module, which will be specific at least to the particular CPU vendor, sometimes also to the CPU Model (e.g. the operations is done differently in an 64-bit AMD processor than it is in a 32-bit AMD processor. I once played with a Linux drivers to set the clock speeds of AMD processors).

This driver will be controlled by a "governor" process that takes as input the configuration settings (policy) you're already using, the current load on the CPU (and often some "load history" too, to reduce too many switches) and other sources such as CPU temperature, power left in battery (if applicable). [In mobile devices, the temperature of the CPU is definitely an input into the equation, since most modern CPUs and GPUs are able to draw much more power than the device can dissipate, thus overheating the chip if the power setting is left on a high setting for too long]

Unfortunately, you need to know a lot more details than "I want to run this fast" before you can do this. There are BIOS tables (ACPI and/or other vendor specific tables) that define what voltage to use at what frequency, and you will need to set the voltage first, then the clock-speed when going up in speed, and the clock speed then voltage when going down in speed. The tables will most often not contain ALL the speeds the CPU can go at, but a "full speed", "medium speed" and "slow speed" setting. [And there will be multiple tables for different types of CPU's, since the BIOS doesn't know if the person building the system will use a high power, high speed CPU or a low speed, low power CPU that].

There are also registers that need to be programmed to determine how long the CPU should "sleep" before it switches to the new speed, to allow the PLL's (that control the clock multipliers) to stabilize. This means that you don't want to switch too often.

The system also needs to know that the clock-frequency has changed so that any processing that depends on the CPU-speed can be adjusted (e.g. things that use the RDTSC instruciton on x86 to measure short times will need to adjust their timings based on a new setting).

If you don't get ALL of these things perfect, you will have an unstable system (and in a mobile device, you could even "fry" the chip - or the user!).

It is not clear what you intend to do, but in general, it's better to leave these things to the governor that already is in the system than to try to make a better system - almost all attempts to make this "better" will fail.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top