123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "governors.h"
- #include "logging.h"
- #include <stdio.h>
- #include <unistd.h>
- #include <linux/limits.h>
- static char initial[32];
- void update_initial_gov_state()
- {
- static char* command = "cpugovctl get";
- FILE* f = popen( command, "r" );
- if( !f )
- FATAL_ERRORNO( "Failed to launch \"%s\" script", command );
- if( !fgets( initial, sizeof(initial)-1, f ) )
- FATAL_ERROR( "Failed to get output from \"%s\"", command );
- pclose(f);
- strtok( initial, "\n" );
- }
- void set_governors( const char* value )
- {
- const char* newval = value ? value : initial;
- LOG_MSG("Setting governors to %s\n", newval ? newval : "initial values");
- char command[PATH_MAX] = {};
- snprintf( command, sizeof(command), "cpugovctl set %s", newval );
- FILE* f = popen( command, "r" );
- if( !f )
- FATAL_ERRORNO( "Failed to launch %s script", command );
- pclose(f);
- }
- const char* get_initial_governor()
- {
- return initial;
- }
|