Making the hotplug thread nice+10 makes all threads created from it also low priority.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/cgminer.c b/cgminer.c
index d9104f4..dcf014e 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4806,6 +4806,18 @@ void zero_stats(void)
}
}
+static void set_highprio(void)
+{
+#ifndef WIN32
+ int ret = nice(-10);
+
+ if (!ret)
+ applog(LOG_DEBUG, "Unable to set thread to high priority");
+#else
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
+#endif
+}
+
static void set_lowprio(void)
{
#ifndef WIN32
@@ -7201,6 +7213,7 @@ void *miner_thread(void *userdata)
applog(LOG_DEBUG, "Waiting on sem in miner thread");
cgsem_wait(&mythr->sem);
+ set_highprio();
cgpu->last_device_valid_work = time(NULL);
drv->hash_work(mythr);
out:
@@ -8366,8 +8379,6 @@ static void *hotplug_thread(void __maybe_unused *userdata)
RenameThread("Hotplug");
- set_lowprio();
-
hotplug_mode = true;
cgsleep_ms(5000);