simplified some lines of code and updated README
This commit is contained in:
parent
a14428a111
commit
38fd93cc43
|
@ -26,7 +26,7 @@ Run `make clean` to remove the compiled binary (note: only from `bin`, to remove
|
||||||
## How it works
|
## How it works
|
||||||
The program checks the available frequency steps supported by your CPU and uses them to set the maximum frequency your cpufreq governor may choose for it to run at.
|
The program checks the available frequency steps supported by your CPU and uses them to set the maximum frequency your cpufreq governor may choose for it to run at.
|
||||||
|
|
||||||
Every second, the program reads the temperature of the CPU and two thresholds, a minimum and maximum temperature you provide it with, to set this maximum frequency.
|
Every n ammount of seconds, set by the user at build time, the program reads the temperature of the CPU and two thresholds, a minimum and maximum temperature you provide it with, to set this maximum frequency.
|
||||||
|
|
||||||
Any time the temperature hits the upper threshold, the maximum frequency will be lowered by one step, until the temperature is below the threshold or the minimum step is reached.
|
Any time the temperature hits the upper threshold, the maximum frequency will be lowered by one step, until the temperature is below the threshold or the minimum step is reached.
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ void changespeed(int threads, char* step){
|
||||||
FILE* file;
|
FILE* file;
|
||||||
for (i=0; i < threads; i++){
|
for (i=0; i < threads; i++){
|
||||||
sprintf(filename, MAXSPDPREFIX"%d"MAXSPDSUFFIX, i);
|
sprintf(filename, MAXSPDPREFIX"%d"MAXSPDSUFFIX, i);
|
||||||
file = fopen(filename, "w");
|
if ((file = fopen(filename, "w")) != NULL){
|
||||||
if (file != NULL){
|
|
||||||
fprintf(file, "%s\n", step);
|
fprintf(file, "%s\n", step);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
@ -145,8 +144,8 @@ int main(int argc, char** argv){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* try to open scaling_available_frequencies, exit on fail */
|
/* try to open scaling_available_frequencies, exit on fail */
|
||||||
FILE *freqsfile = fopen(FREQS, "r");
|
FILE *freqsfile;
|
||||||
if (freqsfile == NULL){
|
if ((freqsfile = fopen(FREQS, "r")) == NULL){
|
||||||
fprintf(stderr, "error: couldn't open scaling_available_frequencies\n");
|
fprintf(stderr, "error: couldn't open scaling_available_frequencies\n");
|
||||||
fprintf(stderr, " check that you have support for cpufreq\n");
|
fprintf(stderr, " check that you have support for cpufreq\n");
|
||||||
fprintf(stderr, " in your kernel and that the program is\n");
|
fprintf(stderr, " in your kernel and that the program is\n");
|
||||||
|
@ -170,8 +169,8 @@ int main(int argc, char** argv){
|
||||||
free(freqsfilec);
|
free(freqsfilec);
|
||||||
fclose(freqsfile);
|
fclose(freqsfile);
|
||||||
/* try to open scaling_maximum_frequency, exit on fail */
|
/* try to open scaling_maximum_frequency, exit on fail */
|
||||||
FILE* curmaxfile = fopen(MAXSPDPREFIX"0"MAXSPDSUFFIX, "r");
|
FILE* curmaxfile;
|
||||||
if (curmaxfile == NULL){
|
if ((curmaxfile = fopen(MAXSPDPREFIX"0"MAXSPDSUFFIX, "r")) == NULL){
|
||||||
fprintf(stderr, "error: couldn't open scaling_maximum_frequency\n");
|
fprintf(stderr, "error: couldn't open scaling_maximum_frequency\n");
|
||||||
fprintf(stderr, " check that you have support for cpufreq\n");
|
fprintf(stderr, " check that you have support for cpufreq\n");
|
||||||
fprintf(stderr, " in your kernel and that the program is\n");
|
fprintf(stderr, " in your kernel and that the program is\n");
|
||||||
|
|
Loading…
Reference in New Issue