Reputation: 7248
Does an API (in C) exist on Linux to allow a process to dynamically change the voltage or the frequency of the core it runs on?
Upvotes: 1
Views: 951
Reputation: 475
CPU Dynamic Voltage-Frequency Scaling Example:
# See availables operation performance points
cat /sys/class/devices/system/cpu/cpu0/scaling_available_frequencies
384000 460800 600000 672000 768000 864000 960000 1248000 1344000 1478400 1555200
# See current core frequency
cat /sys/devices/system/cpu/cpu0/scaling_cur_freq
384000
# See current core voltage
cat /sys/class/regulator/regulator.3/microvolts
785000
# Change CPU speed to 1248000 MHz
echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
cat /sys/devices/system/cpu/cpu0/scaling_cur_freq
1248000
cat /sys/class/regulator/regulator.3/microvolts
980000
Upvotes: 0
Reputation: 121
You can change the frequency voltage pair by writing to: /sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed file. There is a file for each hardware thread. However, you can only change the frequency for the entire chip (all the cores). You can find the available frequencies from: /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
If you do not have this folder, check if your processor has Enhanced Intel SpeedStep® Technology available. If it has, go to the BIOS and enable it and you will see the folder. One more thing, you might need to enable/install the cpufreq module.
Hope it helps someone since the original position is old.
Upvotes: 0
Reputation: 1508
There might be such a library, but even if it doesn't, you can always open the files under /sys/devices/system/cpu that configure the behavior of the CPU.
Take a look to the files under /sys/devices/system/cpu/cpuX/cpufreq .
Upvotes: 1