|
|
@ -1014,7 +1014,7 @@ void kill_work(void) |
|
|
|
|
|
|
|
|
|
|
|
/* Kill the watchdog thread */ |
|
|
|
/* Kill the watchdog thread */ |
|
|
|
thr = &thr_info[watchdog_thr_id]; |
|
|
|
thr = &thr_info[watchdog_thr_id]; |
|
|
|
pthread_cancel(thr->pth); |
|
|
|
pthread_cancel(*thr->pth); |
|
|
|
|
|
|
|
|
|
|
|
/* Stop the mining threads*/ |
|
|
|
/* Stop the mining threads*/ |
|
|
|
for (i = 0; i < mining_threads; i++) { |
|
|
|
for (i = 0; i < mining_threads; i++) { |
|
|
@ -1023,14 +1023,14 @@ void kill_work(void) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
tq_freeze(thr->q); |
|
|
|
tq_freeze(thr->q); |
|
|
|
/* No need to check if this succeeds or not */ |
|
|
|
/* No need to check if this succeeds or not */ |
|
|
|
pthread_cancel(thr->pth); |
|
|
|
pthread_cancel(*thr->pth); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Stop the others */ |
|
|
|
/* Stop the others */ |
|
|
|
thr = &thr_info[stage_thr_id]; |
|
|
|
thr = &thr_info[stage_thr_id]; |
|
|
|
pthread_cancel(thr->pth); |
|
|
|
pthread_cancel(*thr->pth); |
|
|
|
thr = &thr_info[longpoll_thr_id]; |
|
|
|
thr = &thr_info[longpoll_thr_id]; |
|
|
|
pthread_cancel(thr->pth); |
|
|
|
pthread_cancel(*thr->pth); |
|
|
|
|
|
|
|
|
|
|
|
wc = calloc(1, sizeof(*wc)); |
|
|
|
wc = calloc(1, sizeof(*wc)); |
|
|
|
if (unlikely(!wc)) { |
|
|
|
if (unlikely(!wc)) { |
|
|
@ -2736,7 +2736,7 @@ static void stop_longpoll(void) |
|
|
|
struct thr_info *thr = &thr_info[longpoll_thr_id]; |
|
|
|
struct thr_info *thr = &thr_info[longpoll_thr_id]; |
|
|
|
|
|
|
|
|
|
|
|
tq_freeze(thr->q); |
|
|
|
tq_freeze(thr->q); |
|
|
|
pthread_cancel(thr->pth); |
|
|
|
pthread_cancel(*thr->pth); |
|
|
|
have_longpoll = false; |
|
|
|
have_longpoll = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2747,9 +2747,9 @@ static void start_longpoll(void) |
|
|
|
struct thr_info *thr = &thr_info[longpoll_thr_id]; |
|
|
|
struct thr_info *thr = &thr_info[longpoll_thr_id]; |
|
|
|
|
|
|
|
|
|
|
|
tq_thaw(thr->q); |
|
|
|
tq_thaw(thr->q); |
|
|
|
if (unlikely(pthread_create(&thr->pth, NULL, longpoll_thread, thr))) |
|
|
|
if (unlikely(thr_info_create(thr, NULL, longpoll_thread, thr))) |
|
|
|
quit(1, "longpoll thread create failed"); |
|
|
|
quit(1, "longpoll thread create failed"); |
|
|
|
pthread_detach(thr->pth); |
|
|
|
pthread_detach(*thr->pth); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void restart_longpoll(void) |
|
|
|
static void restart_longpoll(void) |
|
|
@ -2764,7 +2764,7 @@ static void reinit_cputhread(int thr_id) |
|
|
|
struct thr_info *thr = &thr_info[thr_id]; |
|
|
|
struct thr_info *thr = &thr_info[thr_id]; |
|
|
|
|
|
|
|
|
|
|
|
tq_freeze(thr->q); |
|
|
|
tq_freeze(thr->q); |
|
|
|
if (!(pthread_cancel(thr->pth)) && pthread_join(thr->pth, NULL)) { |
|
|
|
if (!(pthread_cancel(*thr->pth)) && pthread_join(*thr->pth, NULL)) { |
|
|
|
applog(LOG_ERR, "Failed to pthread_join in reinit_cputhread"); |
|
|
|
applog(LOG_ERR, "Failed to pthread_join in reinit_cputhread"); |
|
|
|
goto failed_out; |
|
|
|
goto failed_out; |
|
|
|
} |
|
|
|
} |
|
|
@ -2774,7 +2774,7 @@ static void reinit_cputhread(int thr_id) |
|
|
|
|
|
|
|
|
|
|
|
thread_reportin(thr); |
|
|
|
thread_reportin(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(pthread_create(&thr->pth, NULL, miner_thread, thr))) { |
|
|
|
if (unlikely(thr_info_create(thr, NULL, miner_thread, thr))) { |
|
|
|
applog(LOG_ERR, "thread %d create failed", thr_id); |
|
|
|
applog(LOG_ERR, "thread %d create failed", thr_id); |
|
|
|
goto failed_out; |
|
|
|
goto failed_out; |
|
|
|
} |
|
|
|
} |
|
|
@ -2792,7 +2792,7 @@ static void reinit_gputhread(int thr_id) |
|
|
|
char name[256]; |
|
|
|
char name[256]; |
|
|
|
|
|
|
|
|
|
|
|
tq_freeze(thr->q); |
|
|
|
tq_freeze(thr->q); |
|
|
|
if (!(pthread_cancel(thr->pth)) && pthread_join(thr->pth, NULL)) { |
|
|
|
if (!(pthread_cancel(*thr->pth)) && pthread_join(*thr->pth, NULL)) { |
|
|
|
applog(LOG_ERR, "Failed to pthread_join in reinit_gputhread"); |
|
|
|
applog(LOG_ERR, "Failed to pthread_join in reinit_gputhread"); |
|
|
|
goto failed_out; |
|
|
|
goto failed_out; |
|
|
|
} |
|
|
|
} |
|
|
@ -2809,7 +2809,7 @@ static void reinit_gputhread(int thr_id) |
|
|
|
|
|
|
|
|
|
|
|
thread_reportin(thr); |
|
|
|
thread_reportin(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(pthread_create(&thr->pth, NULL, gpuminer_thread, thr))) { |
|
|
|
if (unlikely(thr_info_create(thr, NULL, gpuminer_thread, thr))) { |
|
|
|
applog(LOG_ERR, "thread %d create failed", thr_id); |
|
|
|
applog(LOG_ERR, "thread %d create failed", thr_id); |
|
|
|
goto failed_out; |
|
|
|
goto failed_out; |
|
|
|
} |
|
|
|
} |
|
|
@ -3272,7 +3272,7 @@ int main (int argc, char *argv[]) |
|
|
|
quit(1, "Failed to tq_new"); |
|
|
|
quit(1, "Failed to tq_new"); |
|
|
|
|
|
|
|
|
|
|
|
/* start work I/O thread */ |
|
|
|
/* start work I/O thread */ |
|
|
|
if (pthread_create(&thr->pth, NULL, workio_thread, thr)) |
|
|
|
if (thr_info_create(thr, NULL, workio_thread, thr)) |
|
|
|
quit(1, "workio thread create failed"); |
|
|
|
quit(1, "workio thread create failed"); |
|
|
|
|
|
|
|
|
|
|
|
/* init longpoll thread info */ |
|
|
|
/* init longpoll thread info */ |
|
|
@ -3303,9 +3303,9 @@ int main (int argc, char *argv[]) |
|
|
|
if (!thr->q) |
|
|
|
if (!thr->q) |
|
|
|
quit(1, "Failed to tq_new"); |
|
|
|
quit(1, "Failed to tq_new"); |
|
|
|
/* start stage thread */ |
|
|
|
/* start stage thread */ |
|
|
|
if (pthread_create(&thr->pth, NULL, stage_thread, thr)) |
|
|
|
if (thr_info_create(thr, NULL, stage_thread, thr)) |
|
|
|
quit(1, "stage thread create failed"); |
|
|
|
quit(1, "stage thread create failed"); |
|
|
|
pthread_detach(thr->pth); |
|
|
|
pthread_detach(*thr->pth); |
|
|
|
|
|
|
|
|
|
|
|
/* Flag the work as ready forcing the mining threads to wait till we
|
|
|
|
/* Flag the work as ready forcing the mining threads to wait till we
|
|
|
|
* actually put something into the queue */ |
|
|
|
* actually put something into the queue */ |
|
|
@ -3374,7 +3374,7 @@ int main (int argc, char *argv[]) |
|
|
|
|
|
|
|
|
|
|
|
thread_reportin(thr); |
|
|
|
thread_reportin(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(pthread_create(&thr->pth, NULL, gpuminer_thread, thr))) |
|
|
|
if (unlikely(thr_info_create(thr, NULL, gpuminer_thread, thr))) |
|
|
|
quit(1, "thread %d create failed", i); |
|
|
|
quit(1, "thread %d create failed", i); |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
} |
|
|
|
} |
|
|
@ -3402,7 +3402,7 @@ int main (int argc, char *argv[]) |
|
|
|
|
|
|
|
|
|
|
|
thread_reportin(thr); |
|
|
|
thread_reportin(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(pthread_create(&thr->pth, NULL, miner_thread, thr))) |
|
|
|
if (unlikely(thr_info_create(thr, NULL, miner_thread, thr))) |
|
|
|
quit(1, "thread %d create failed", i); |
|
|
|
quit(1, "thread %d create failed", i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3414,7 +3414,7 @@ int main (int argc, char *argv[]) |
|
|
|
watchdog_thr_id = mining_threads + 2; |
|
|
|
watchdog_thr_id = mining_threads + 2; |
|
|
|
thr = &thr_info[watchdog_thr_id]; |
|
|
|
thr = &thr_info[watchdog_thr_id]; |
|
|
|
/* start wakeup thread */ |
|
|
|
/* start wakeup thread */ |
|
|
|
if (pthread_create(&thr->pth, NULL, watchdog_thread, NULL)) |
|
|
|
if (thr_info_create(thr, NULL, watchdog_thread, NULL)) |
|
|
|
quit(1, "wakeup thread create failed"); |
|
|
|
quit(1, "wakeup thread create failed"); |
|
|
|
|
|
|
|
|
|
|
|
/* Restart count as it will be wrong till all threads are started */ |
|
|
|
/* Restart count as it will be wrong till all threads are started */ |
|
|
@ -3435,12 +3435,12 @@ int main (int argc, char *argv[]) |
|
|
|
/* Create curses input thread for keyboard input */ |
|
|
|
/* Create curses input thread for keyboard input */ |
|
|
|
input_thr_id = mining_threads + 4; |
|
|
|
input_thr_id = mining_threads + 4; |
|
|
|
thr = &thr_info[input_thr_id]; |
|
|
|
thr = &thr_info[input_thr_id]; |
|
|
|
if (pthread_create(&thr->pth, NULL, input_thread, thr)) |
|
|
|
if (thr_info_create(thr, NULL, input_thread, thr)) |
|
|
|
quit(1, "input thread create failed"); |
|
|
|
quit(1, "input thread create failed"); |
|
|
|
pthread_detach(thr->pth); |
|
|
|
pthread_detach(*thr->pth); |
|
|
|
|
|
|
|
|
|
|
|
/* main loop - simply wait for workio thread to exit */ |
|
|
|
/* main loop - simply wait for workio thread to exit */ |
|
|
|
pthread_join(thr_info[work_thr_id].pth, NULL); |
|
|
|
pthread_join(*thr_info[work_thr_id].pth, NULL); |
|
|
|
applog(LOG_INFO, "workio thread dead, exiting."); |
|
|
|
applog(LOG_INFO, "workio thread dead, exiting."); |
|
|
|
|
|
|
|
|
|
|
|
gettimeofday(&total_tv_end, NULL); |
|
|
|
gettimeofday(&total_tv_end, NULL); |
|
|
|