2

I have a program and I want to measure its running time based on the input, but my system is old and has overheating problems. Leaving a program running at full CPU usage for around 1 minute usually makes it hibernate/turn off from overheating.

I'm looking for something to limit the cpu usage. I've looked at cpulimit but it works by pausing and continuing the program multiple times. How would that work in this case? Would it be an estimate of running the program in a slower cpu, or would it corrupt timing results?

Is there some other software that limits the cpu usage more uniformly?

devil0150
  • 191
  • 2
  • 12

1 Answers1

6

Sounds like you want to limit your cpu's speed, or frequency. The Linux kernel should be able to do that, if your cpu supports it, you can have it only speed up to a lower maximum. For example if your cpu normally runs at 1, 2, or 3 GHz, you tell it to only go to 1 or 2 GHz and it should stay much cooler than when it's at 3 GHz.

You could use the sysfs / procfs interface directly, but using cpufreq is probably much easier. On Debian/Ubuntu the package is called cpufrequtils, here's a Ubuntu package search for it.

Running cpufreq-info should tell you the available cpu's & frequencies & governors, and if the cpu's "run at the same hardware frequency" or "need to have their frequency coordinated by software".

For example, to set the maximum frequency of cpu0 to 1.5GHz, you'd run:
cpufreq-set --cpu 0 --max 1.5GHz

The different governors and settings decide when to speed up & slow down the cpu, setting them "wrong" could have the cpu seem like it never wants to speed up, or never wants to slow down, but in general I think the conservative governor is better than the ondemand governor (it's usually the default and seems to speed up if you even look at your computer funny lately ;-) For example, this command tells the conservative governor to slow down if the cpu's only 50% busy:
echo 50 | sudo tee /sys/devices/system/cpu/cpufreq/conservative/down_threshold


And of course, I'm suspecting something is physically wrong with your computer. It shouldn't be shutting off like that.

  • Is lint blocking the fan & airflow? Air vents blocked?
  • Is the fan running at full speed, or running at all?
  • Is the heat sink properly attached or damaged?

Is it really shutting down from the cpu overheating (logs support it), or is the power supply giving up / overheating?

Xen2050
  • 14,391