1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-27 15:04:17 +00:00

Set priority of various threads if possible.

Conflicts:
	cgminer.c
This commit is contained in:
Con Kolivas 2013-11-16 11:42:38 +11:00 committed by Noel Maersk
parent e9f20f5e0b
commit 39121183e1

View File

@ -4314,6 +4314,30 @@ 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
int ret = nice(10);
if (!ret)
applog(LOG_INFO, "Unable to set thread to low priority");
#else
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
#endif
}
#ifdef HAVE_CURSES
static void display_pools(void)
{
@ -4721,6 +4745,7 @@ static void *api_thread(void *userdata)
RenameThread("api");
set_lowprio();
api(api_thr_id);
PTH(mythr) = 0L;
@ -6383,6 +6408,7 @@ void *miner_thread(void *userdata)
applog(LOG_DEBUG, "Waiting on sem in miner thread");
cgsem_wait(&mythr->sem);
set_highprio();
drv->hash_work(mythr);
out:
drv->thread_shutdown(mythr);
@ -6661,6 +6687,8 @@ static void *watchpool_thread(void __maybe_unused *userdata)
RenameThread("watchpool");
set_lowprio();
while (42) {
struct timeval now;
int i;
@ -6744,6 +6772,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
RenameThread("watchdog");
set_lowprio();
memset(&zero_tv, 0, sizeof(struct timeval));
cgtime(&rotate_tv);