mbpfan-josie

Configure timer slack for 1 second

This allows the kernel scheduler to coalesce wakeups, improving
battery life.  Linux defaults to 50 ms slack.  Reference:

http://lwn.net/Articles/369549/

6aba92d64915fc3ea71ce651133ab16804ca9091
Andrew Gaul <andrew@gaul.org> · 2017-07-12T18:11 · browse files at this commit

parents: e8850f6

diff --git a/src/daemon.c b/src/daemon.c
index 7a94985..a4574e3 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -17,6 +17,7 @@
  */
 
 
+#include <sys/prctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
@@ -153,6 +154,11 @@ void go_daemon(void (*fan_control)())
         openlog(PROGRAM_NAME, LOG_CONS, LOG_USER);
     }
 
+    // configure timer slack
+    int err = prctl(PR_SET_TIMERSLACK, 1000 * 1000 * 1000, 0, 0, 0);
+    if (err == -1) {
+        perror("prctl");
+    }
 
     pid_t pid_slave;
     pid_t sid_slave;