Skip to content

Instantly share code, notes, and snippets.

@x42
Created October 28, 2017 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x42/39b3b47ad9733e4a35f801c3cb5dad6e to your computer and use it in GitHub Desktop.
Save x42/39b3b47ad9733e4a35f801c3cb5dad6e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
static int pm_qos_fd = -1;
static void start_low_latency(void) {
int32_t target = 0;
if (pm_qos_fd >= 0) {
return;
}
pm_qos_fd = open("/dev/cpu_dma_latency", O_RDWR);
if (pm_qos_fd < 0) {
fprintf(stderr, "Failed to open PM QOS file: %s",
strerror(errno));
exit(errno);
}
write(pm_qos_fd, &target, sizeof(target));
}
static void stop_low_latency(void) {
if (pm_qos_fd >= 0)
close(pm_qos_fd);
}
int main (int argc, char **argv) {
start_low_latency();
while (1) {
sleep (1);
}
stop_low_latency();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment