Skip to content

Commit 6aba92d

Browse files
committed
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/
1 parent e8850f6 commit 6aba92d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/daemon.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919

20+
#include <sys/prctl.h>
2021
#include <sys/types.h>
2122
#include <sys/stat.h>
2223
#include <stdio.h>
@@ -153,6 +154,11 @@ void go_daemon(void (*fan_control)())
153154
openlog(PROGRAM_NAME, LOG_CONS, LOG_USER);
154155
}
155156

157+
// configure timer slack
158+
int err = prctl(PR_SET_TIMERSLACK, 1000 * 1000 * 1000, 0, 0, 0);
159+
if (err == -1) {
160+
perror("prctl");
161+
}
156162

157163
pid_t pid_slave;
158164
pid_t sid_slave;

0 commit comments

Comments
 (0)