Browse Source

Overlap queued decrementing with staged incrementing.

Con Kolivas 13 years ago
parent
commit
5fadfdb219
2 changed files with 12 additions and 2 deletions
  1. 11 2
      cgminer.c
  2. 1 0
      miner.h

+ 11 - 2
cgminer.c

@@ -2427,7 +2427,7 @@ static void *get_work_thread(void *userdata)
 		}
 		}
 		fail_pause = opt_fail_pause;
 		fail_pause = opt_fail_pause;
 
 
-		dec_queued(pool);
+		ret_work->queued = true;
 	}
 	}
 
 
 	applog(LOG_DEBUG, "Pushing work to requesting thread");
 	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)
 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);
 	mutex_lock(stgd_lock);
 	if (likely(!getq->frozen)) {
 	if (likely(!getq->frozen)) {
@@ -2901,6 +2906,10 @@ static bool hash_push(struct work *work)
 		rc = false;
 		rc = false;
 	pthread_cond_signal(&getq->cond);
 	pthread_cond_signal(&getq->cond);
 	mutex_unlock(stgd_lock);
 	mutex_unlock(stgd_lock);
+
+	if (dec)
+		dec_queued(work->pool);
+
 	return rc;
 	return rc;
 }
 }
 
 

+ 1 - 0
miner.h

@@ -795,6 +795,7 @@ struct work {
 	bool		stale;
 	bool		stale;
 	bool		mandatory;
 	bool		mandatory;
 	bool		block;
 	bool		block;
+	bool		queued;
 
 
 	unsigned int	work_block;
 	unsigned int	work_block;
 	int		id;
 	int		id;