Skip to content

Commit 7c02663

Browse files
author
Naoki Shibata
committed
Add explanation for options
1 parent 9878f4d commit 7c02663

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

README.md

+36-8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,35 @@ tool controls the CPU temperature more aggressively than thermald.
4444
`cputemp [<options>]`
4545

4646

47+
### Options
48+
49+
`--sensor <sensor name>`
50+
51+
Specifies the name of sensor that gives the CPU temperature.
52+
53+
`--period <seconds>`
54+
55+
Specifies the interval at which temperature is checked and CPU
56+
frequency is controlled.
57+
58+
`--temp <target temperature>`
59+
60+
Specify target CPU temperature.
61+
62+
`--daemon <pid file name>`
63+
64+
Start this tool as a daemon. If this tool is already running as a
65+
daemon, it will be restarted with the new setting.
66+
67+
`--kill-daemon <pid file name>`
68+
69+
Kill already running daemon.
70+
71+
`--verbose`
72+
73+
Turn on verbose mode.
74+
75+
4776
### Description
4877

4978
This tool monitors temperature obtained by the sensor specified by
@@ -90,18 +119,17 @@ controlled by `--verbose` option.
90119

91120
```
92121
$ sudo ./cputemp --sensor k10temp --temp 80 --verbose
93-
[sudo] password for shibatch:
94122
Sensor file name : /sys/class/hwmon/hwmon1/temp1_input
95123
Max freq : 5881 MHz
96124
Min freq : 400 MHz
97-
Cur freq : 5488.64 MHz
98-
CPU freq = 476.966 MHz, scaling_max_freq = 400 MHz, CPU temp = 53.75 C, target temp = 80 C
99-
CPU freq = 564.43 MHz, scaling_max_freq = 925 MHz, CPU temp = 53.75 C, target temp = 80 C
100-
CPU freq = 1112.53 MHz, scaling_max_freq = 1450 MHz, CPU temp = 53.75 C, target temp = 80 C
101-
CPU freq = 1496.2 MHz, scaling_max_freq = 1975 MHz, CPU temp = 53.75 C, target temp = 80 C
102-
CPU freq = 2500 MHz, scaling_max_freq = 2500 MHz, CPU temp = 53.75 C, target temp = 80 C
125+
Cur freq : 5039.77 MHz
126+
CPU freq = 476.98 MHz, scaling_max_freq = 5881 MHz, CPU temp = 64.625 C, target temp = 80 C
127+
CPU freq = 674.05 MHz, scaling_max_freq = 5881 MHz, CPU temp = 64.5 C, target temp = 80 C
128+
CPU freq = 564.43 MHz, scaling_max_freq = 5881 MHz, CPU temp = 64.375 C, target temp = 80 C
129+
CPU freq = 674.05 MHz, scaling_max_freq = 5881 MHz, CPU temp = 64.25 C, target temp = 80 C
130+
CPU freq = 3524.17 MHz, scaling_max_freq = 5881 MHz, CPU temp = 64.25 C, target temp = 80 C
103131
^C
104-
$
132+
$
105133
```
106134

107135
You should be able to observe that the CPU frequency is lowered and

cputemp.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,24 @@ int main(int argc, char **argv) {
230230

231231
const double maxFreq = getMaxFreq(), minFreq = getMinFreq();
232232

233-
setFreq(maxFreq);
234-
for(int i=0;i<10 && getFreq() != maxFreq;i++)
233+
setFreq(minFreq);
234+
for(int i=0;i<10 && getFreq() != minFreq;i++)
235235
this_thread::sleep_for(chrono::milliseconds(100));
236236

237-
if (getFreq() != maxFreq) {
238-
cerr << "Could not set scaling_max_freq to the max freqency." << endl;
239-
cerr << "Max freq : " << (getMaxFreq() / 1000000.0) << " MHz" << endl;
237+
if (getFreq() != minFreq) {
238+
cerr << "Could not set scaling_max_freq to the min freqency." << endl;
239+
cerr << "Min freq : " << (getMinFreq() / 1000000.0) << " MHz" << endl;
240240
cerr << "scaling_max_freq : " << (getFreq() / 1000000.0) << " MHz" << endl;
241241
exit(-1);
242242
}
243243

244-
setFreq(minFreq);
245-
for(int i=0;i<10 && getFreq() != minFreq;i++)
244+
setFreq(maxFreq);
245+
for(int i=0;i<10 && getFreq() != maxFreq;i++)
246246
this_thread::sleep_for(chrono::milliseconds(100));
247247

248-
if (getFreq() != minFreq) {
249-
cerr << "Could not set scaling_max_freq to the min freqency." << endl;
250-
cerr << "Min freq : " << (getMinFreq() / 1000000.0) << " MHz" << endl;
248+
if (getFreq() != maxFreq) {
249+
cerr << "Could not set scaling_max_freq to the max freqency." << endl;
250+
cerr << "Max freq : " << (getMaxFreq() / 1000000.0) << " MHz" << endl;
251251
cerr << "scaling_max_freq : " << (getFreq() / 1000000.0) << " MHz" << endl;
252252
exit(-1);
253253
}
@@ -280,7 +280,7 @@ int main(int argc, char **argv) {
280280

281281
if (verbose) {
282282
cout << "CPU freq = " << (getCurFreq() / 1000000.0) << " MHz, ";
283-
cout << "scaling_max_freq = " << (curFreq / 1000000.0) << " MHz, ";
283+
cout << "scaling_max_freq = " << (getFreq() / 1000000.0) << " MHz, ";
284284
cout << "CPU temp = " << curTemp << " C, ";
285285
cout << "target temp = " << targetTemp << " C" << endl;
286286
}

0 commit comments

Comments
 (0)