Permalink
Browse files

o Ah, cool, on linux it is possible to set the nice level of

  threads.
  • Loading branch information...
hzeller committed Oct 14, 2012
1 parent d119a0a commit 1d1c2e13de56d7fa50688ec4d8b5658ad2cee149
Showing with 8 additions and 2 deletions.
  1. +8 −2 util.cc
View
10 util.cc
@@ -17,10 +17,12 @@
#include "util.h"
-#include <linux/sched.h> // for SCHED_IDLE, <sched.h> doesn't do it everywhere
-
#include <assert.h>
+#include <linux/sched.h> // for SCHED_IDLE, <sched.h> doesn't do it everywhere
#include <stdio.h>
+#include <sys/resource.h>
+#include <sys/syscall.h> // need to call gettid syscall.
+#include <sys/time.h>
#include <sys/time.h>
#include <syslog.h>
@@ -84,6 +86,10 @@ bool folve::HasSuffix(const std::string &str, const std::string &suffix) {
}
void *folve::Thread::PthreadCallRun(void *tobject) {
+ // Some hardcoded nicification of the thread. We use it for the pre-buffering
+ // which is nice-to-have and shouldn't interfere too much with other stuff.
+ setpriority(PRIO_PROCESS, syscall(SYS_gettid), 2);
+
reinterpret_cast<folve::Thread*>(tobject)->Run();
return NULL;
}

0 comments on commit 1d1c2e1

Please sign in to comment.