aboutsummaryrefslogtreecommitdiff
path: root/src/util/batchpriority.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/batchpriority.cpp')
-rw-r--r--src/util/batchpriority.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util/batchpriority.cpp b/src/util/batchpriority.cpp
new file mode 100644
index 0000000000..c73aef1eb4
--- /dev/null
+++ b/src/util/batchpriority.cpp
@@ -0,0 +1,26 @@
+// Copyright (c) 2023 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <logging.h>
+#include <util/syserror.h>
+
+#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
+#include <pthread.h>
+#include <pthread_np.h>
+#endif
+
+#ifndef WIN32
+#include <sched.h>
+#endif
+
+void ScheduleBatchPriority()
+{
+#ifdef SCHED_BATCH
+ const static sched_param param{};
+ const int rc = pthread_setschedparam(pthread_self(), SCHED_BATCH, &param);
+ if (rc != 0) {
+ LogPrintf("Failed to pthread_setschedparam: %s\n", SysErrorString(rc));
+ }
+#endif
+}