From 5fadfdb2195b941ae04e4e12c7c7e2addde9594d Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 16 Aug 2012 09:19:45 +1000 Subject: [PATCH] Overlap queued decrementing with staged incrementing. --- cgminer.c | 13 +++++++++++-- miner.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cgminer.c b/cgminer.c index 827e217e..6f500f0f 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2427,7 +2427,7 @@ static void *get_work_thread(void *userdata) } fail_pause = opt_fail_pause; - dec_queued(pool); + ret_work->queued = true; } applog(LOG_DEBUG, "Pushing work to requesting thread"); @@ -2890,7 +2890,12 @@ static int tv_sort(struct work *worka, struct work *workb) static bool hash_push(struct work *work) { - bool rc = true; + bool rc = true, dec = false; + + if (work->queued) { + work->queued = false; + dec = true; + } mutex_lock(stgd_lock); if (likely(!getq->frozen)) { @@ -2901,6 +2906,10 @@ static bool hash_push(struct work *work) rc = false; pthread_cond_signal(&getq->cond); mutex_unlock(stgd_lock); + + if (dec) + dec_queued(work->pool); + return rc; } diff --git a/miner.h b/miner.h index f87612ab..d79578ea 100644 --- a/miner.h +++ b/miner.h @@ -795,6 +795,7 @@ struct work { bool stale; bool mandatory; bool block; + bool queued; unsigned int work_block; int id;