]> git.pld-linux.org Git - projects/cleanbuild.git/blame - fixfreq
update docbook-style-xsl; generic exec finder
[projects/cleanbuild.git] / fixfreq
CommitLineData
83d24974 1#!/usr/bin/perl
2
3use Fcntl;
4my $fifo = "/tmp/fixfreq";
5
6system "mkfifo", $fifo;
7chmod 0600, $fifo;
8
9sysopen( READ_PIDS, $fifo, O_NONBLOCK|O_RDONLY) or die "Can't open modem: $!\n";
10
11
12END {
13 set( 0 );
14 close READ_PIDS;
15 unlink $fifo;
16}
17
18sub bye { exit; }
19
20$SIG{TERM} = \&bye;
21$SIG{INT} = \&bye;
22
23my $now_is = "";
24sub set
25{
26 my $num = shift;
27 my $set_to = $num ? "performance" : "ondemand";
28 return if $now_is eq $set_to;
29 $now_is = $set_to;
30 foreach my $gov ( glob "/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor" ) {
31 open GOV, ">", $gov;
32 print GOV $set_to;
33 close GOV;
34 }
35}
36
37my %pids;
38
39while ( 1 ) {
40 foreach my $pid ( keys %pids ) {
41 unless ( -d "/proc/".$pid ) {
42 delete $pids{ $pid };
43 }
44 }
45 while ( my $pid = <READ_PIDS> ) {
46 chomp $pid;
47 if ( -d "/proc/$pid" ) {
48 $pids{ $pid } = 1;
49 }
50 }
51 set( keys %pids );
52 sleep 1;
53}
54
This page took 0.094042 seconds and 4 git commands to generate.