initial commit

This commit is contained in:
klein panic
2024-09-29 02:33:35 -04:00
commit 681acbf5ce
16 changed files with 179 additions and 0 deletions

19
src/cpu_control.c Normal file
View File

@@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // Add this for sysconf()
#include "cpu_control.h"
void set_cpu_governor(const char *governor) {
int cpu_count = sysconf(_SC_NPROCESSORS_ONLN);
for (int i = 0; i < cpu_count; i++) {
char path[64];
sprintf(path, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", i);
FILE *f = fopen(path, "w");
if (f) {
fprintf(f, "%s", governor);
fclose(f);
} else {
perror("Failed to set CPU governor");
}
}
}