Browse Source

Set priority of various threads if possible.

Conflicts:
	cgminer.c
nfactor-troky
Con Kolivas 11 years ago committed by Noel Maersk
parent
commit
39121183e1
  1. 29
      cgminer.c

29
cgminer.c

@ -4314,6 +4314,30 @@ void zero_stats(void) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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);

Loading…
Cancel
Save