From 05421057ae9cedaf1734d4df2c10afc337d28a02 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 3 Dec 2019 18:28:10 +0700 Subject: [PATCH] #1363 Fixed main thread priority. --- src/App.cpp | 2 -- src/base/kernel/Base.cpp | 4 ---- src/base/kernel/Platform.h | 1 - src/base/kernel/Platform_mac.cpp | 5 ----- src/base/kernel/Platform_unix.cpp | 5 ----- src/base/kernel/Platform_win.cpp | 37 ------------------------------- src/core/Miner.cpp | 5 +++++ 7 files changed, 5 insertions(+), 54 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index 1908482c1..3acccc5df 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -90,8 +90,6 @@ int xmrig::App::exec() m_controller->start(); - Platform::setThreadPriority(5); - rc = uv_run(uv_default_loop(), UV_RUN_DEFAULT); uv_loop_close(uv_default_loop()); diff --git a/src/base/kernel/Base.cpp b/src/base/kernel/Base.cpp index 90c7cb57c..5718a115e 100644 --- a/src/base/kernel/Base.cpp +++ b/src/base/kernel/Base.cpp @@ -176,10 +176,6 @@ int xmrig::Base::init() Platform::init(config()->userAgent()); -# ifndef XMRIG_PROXY_PROJECT - Platform::setProcessPriority(config()->cpu().priority()); -# endif - if (isBackground()) { Log::background = true; } diff --git a/src/base/kernel/Platform.h b/src/base/kernel/Platform.h index 3f026f8bd..fe39a69ea 100644 --- a/src/base/kernel/Platform.h +++ b/src/base/kernel/Platform.h @@ -51,7 +51,6 @@ public: static uint32_t setTimerResolution(uint32_t resolution); static void init(const char *userAgent); static void restoreTimerResolution(); - static void setProcessPriority(int priority); static void setThreadPriority(int priority); static inline const char *userAgent() { return m_userAgent; } diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index 146dd52d7..8d9bac3b8 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -83,11 +83,6 @@ void xmrig::Platform::restoreTimerResolution() } -void xmrig::Platform::setProcessPriority(int priority) -{ -} - - void xmrig::Platform::setThreadPriority(int priority) { if (priority == -1) { diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index bbba39f90..b6ca17e4a 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -111,11 +111,6 @@ void xmrig::Platform::restoreTimerResolution() } -void xmrig::Platform::setProcessPriority(int priority) -{ -} - - void xmrig::Platform::setThreadPriority(int priority) { if (priority == -1) { diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index 064c8352f..ad93cb6a7 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -131,43 +131,6 @@ void xmrig::Platform::restoreTimerResolution() } -void xmrig::Platform::setProcessPriority(int priority) -{ - if (priority == -1) { - return; - } - - DWORD prio = IDLE_PRIORITY_CLASS; - switch (priority) - { - case 1: - prio = BELOW_NORMAL_PRIORITY_CLASS; - break; - - case 2: - prio = NORMAL_PRIORITY_CLASS; - break; - - case 3: - prio = ABOVE_NORMAL_PRIORITY_CLASS; - break; - - case 4: - prio = HIGH_PRIORITY_CLASS; - break; - - case 5: - prio = REALTIME_PRIORITY_CLASS; - break; - - default: - break; - } - - SetPriorityClass(GetCurrentProcess(), prio); -} - - void xmrig::Platform::setThreadPriority(int priority) { if (priority == -1) { diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 20ff3fd73..5551268a6 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -263,6 +263,11 @@ public: xmrig::Miner::Miner(Controller *controller) : d_ptr(new MinerPrivate(controller)) { + const int priority = controller->config()->cpu().priority(); + if (priority >= 0) { + Platform::setThreadPriority(std::min(priority + 1, 5)); + } + # ifdef XMRIG_ALGO_RANDOMX Rx::init(this); # endif