Commit f770cc08aefa97181ce303f7aafd6cab3bcb74de

Con Kolivas 2014-02-27T00:01:38

Making the hotplug thread nice+10 makes all threads created from it also low priority.

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);