]> git.pld-linux.org Git - projects/cleanbuild.git/commitdiff
- set cpufreq scaling governor to performance on all cores while building
authorsparky <sparky@pld-linux.org>
Tue, 8 Dec 2009 01:08:17 +0000 (01:08 +0000)
committersparky <sparky@pld-linux.org>
Tue, 8 Dec 2009 01:08:17 +0000 (01:08 +0000)
  something, set to ondemand otherwise

svn-id: @11014

fixfreq [new file with mode: 0755]

diff --git a/fixfreq b/fixfreq
new file mode 100755 (executable)
index 0000000..befec4d
--- /dev/null
+++ b/fixfreq
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+use Fcntl;
+my $fifo = "/tmp/fixfreq";
+
+system "mkfifo", $fifo;
+chmod 0600, $fifo;
+
+sysopen( READ_PIDS, $fifo, O_NONBLOCK|O_RDONLY) or die "Can't open modem: $!\n";
+
+
+END {
+       set( 0 );
+       close READ_PIDS;
+       unlink $fifo;
+}
+
+sub bye { exit; }
+
+$SIG{TERM} = \&bye;
+$SIG{INT} = \&bye;
+
+my $now_is = "";
+sub set
+{
+       my $num = shift;
+       my $set_to = $num ? "performance" : "ondemand";
+       return if $now_is eq $set_to;
+       $now_is = $set_to;
+       foreach my $gov ( glob "/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor" ) {
+               open GOV, ">", $gov;
+               print GOV $set_to;
+               close GOV;
+       }
+}
+
+my %pids;
+
+while ( 1 ) {
+       foreach my $pid ( keys %pids ) {
+               unless ( -d "/proc/".$pid ) {
+                       delete $pids{ $pid };
+               }
+       }
+       while ( my $pid = <READ_PIDS> ) {
+               chomp $pid;
+               if ( -d "/proc/$pid" ) {
+                       $pids{ $pid } = 1;
+               }
+       }
+       set( keys %pids );
+       sleep 1;
+}
+
This page took 0.047941 seconds and 4 git commands to generate.