Skip to content

Instantly share code, notes, and snippets.

@DhruvaG2000
Last active October 31, 2025 10:36
Show Gist options
  • Select an option

  • Save DhruvaG2000/a902b815b5db296bb7096ad7cb093929 to your computer and use it in GitHub Desktop.

Select an option

Save DhruvaG2000/a902b815b5db296bb7096ad7cb093929 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#define QOS_DEV "/dev/cpu_wakeup_latency"
#define LATENCY_VAL "0x7a110" /* <500000 ?unit? in hex */
static volatile int keep_running = 1;
void sig_handler(int sig) {
keep_running = 0;
}
int main(void) {
int fd;
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
fd = open(QOS_DEV, O_RDWR);
if (fd < 0) {
perror("open");
return 1;
}
if (write(fd, LATENCY_VAL, sizeof(LATENCY_VAL) - 1) < 0) {
perror("write");
close(fd);
return 1;
}
printf("QoS set to %s. Press Ctrl+C to exit.\n", LATENCY_VAL);
while (keep_running)
sleep(1);
close(fd);
printf("Released.\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment