aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 46054f5025..8b36c3e5f7 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -31,6 +31,7 @@
#include <algorithm>
#include <fcntl.h>
+#include <sched.h>
#include <sys/resource.h>
#include <sys/stat.h>
@@ -1039,3 +1040,17 @@ fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific)
{
return fs::absolute(path, GetDataDir(net_specific));
}
+
+int ScheduleBatchPriority(void)
+{
+#ifdef SCHED_BATCH
+ const static sched_param param{.sched_priority = 0};
+ if (int ret = pthread_setschedparam(0, SCHED_BATCH, &param)) {
+ LogPrintf("Failed to pthread_setschedparam: %s\n", strerror(errno));
+ return ret;
+ }
+ return 0;
+#else
+ return 1;
+#endif
+}