Commit b1cdacdead258692c12af5949242c5d58ef3c0ee

ckolivas 2012-07-02T11:28:26

Polling every 10ms there's not much point checking the pthread_cond_timedwait as it just adds overhead. Simply check the value of work_restart in the bfl main polling loop.

diff --git a/driver-bitforce.c b/driver-bitforce.c
index 902b5a3..bc5181c 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -137,10 +137,10 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 	struct cgpu_info *bitforce = thr->cgpu;
 	int fdDev = bitforce->device_fd;
 
+	int i, thr_id = thr->id;
 	char pdevbuf[0x100];
 	unsigned char ob[61] = ">>>>>>>>12345678901234567890123456789012123456789012>>>>>>>>";
 	struct timeval tdiff;
-	int i;
 	char *pnoncebuf;
 	char *s;
 	uint32_t nonce;
@@ -215,8 +215,13 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 	/* Now start looking for results. Stupid polling every 10ms... */
 	tdiff.tv_sec = 0;
 	tdiff.tv_usec = 10000;
+
+	work_restart[thr_id].restart = 0;
 	while (42) {
-		int rc = restart_wait(&tdiff);
+		if (unlikely(work_restart[thr_id].restart))
+			return 0;
+		usleep(10000);
+		i += 10;
 
 		BFwrite(fdDev, "ZFX", 3);
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
@@ -226,9 +231,6 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 		}
 		if (pdevbuf[0] != 'B')
 		    break;
-		if (!rc)
-			return 0;
-		i += 10;
 	}
 	applog(LOG_DEBUG, "BitForce waited %dms until %s\n", i, pdevbuf);
 	work->blk.nonce = 0xffffffff;