Skip to content

Instantly share code, notes, and snippets.

@macros
Created April 17, 2017 23:33
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 macros/bbb10dedb8f0bdc582f52e5d663d5d30 to your computer and use it in GitHub Desktop.
Save macros/bbb10dedb8f0bdc582f52e5d663d5d30 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <fcntl.h>
#include <stdint.h>
int main(int argc, char **argv) {
int32_t l;
int fd;
if (argc != 2) {
fprintf(stderr, "Usage: %s <latency in us>\n", argv[0]);
return 2;
}
l = atoi(argv[1]);
printf("setting latency to %d us\n", l);
fd = open("/dev/cpu_dma_latency", O_WRONLY);
if (fd < 0) {
perror("open /dev/cpu_dma_latency");
return 1;
}
if (write(fd, &l, sizeof(l)) != sizeof(l)) {
perror("write to /dev/cpu_dma_latency");
return 1;
}
while (1) pause();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment