On a laptop you typically want to conserve battery power. With NetBSD you can set up sysutils/estd to configure the usage of Enhanced Speedstep technology. Estd monitors the ratio between load and idle states the OS records. Seting high- and low-water marks you can control the load above or below which to switch to the next higher or lower CPU frequency, respectively.

Example:

estd -l 40 -h 70 -b

If the percentage of idle states goes below 40% lower the CPU frequency to conserve battery. If it goes above 70% increase the frequency.

If you are using a multi-core CPU, estd will use the ratio between the sums over all CPUs of load versus idle states.

So, estd takes care of balancing battery power against performance.

To control temperature you can use envsys(4).

Put into /etc/envsys.conf:

coretemp0 {
 sensor0 {
  critical-max = 65C;
 }
}
coretemp1 {
 sensor0 {
  critical-max = 65C;
 }
}

The configuration is activated by issuing

envstat -c /etc/envsys.conf

Now the envsys system will trigger critical events whenever the temperature of one of these sensors goes above 65C. Such an event results in executing the script /etc/powerd/sensor_temperarture.

In this script I put:

 .
 .
 .
case "${2}" in
normal)
 case "${1}" in
 coretemp*)
  echo "estd_flags=\"-l 40 -h 70 -b\"" >/etc/rc.conf.d/estd
  /etc/rc.d/estd restart
  ;;
 esac
 exit 0
 ;;
 .
 .
 .
critical-over)
 case "${1}" in
 coretemp*)
  /etc/rc.d/estd stop
  sysctl -w machdep.est.frequency.target=600
  ;;
 esac
 exit 0
 ;;
 .
 .
 .

It works nicely: the temperature sensor goes above 65C under heavy load, the envsys triggers a critical-over event, the script stops estd and sets the frequency to the lowest possible value on my CPU. Under heavy load it stays there long enough for the sensors to go down to about 52C-55C, before the normal event is triggered, estd is restarted and the heat rises again...