Created
October 28, 2017 13:07
-
-
Save x42/39b3b47ad9733e4a35f801c3cb5dad6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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