bab remove results polling
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/driver-bab.c b/driver-bab.c
index 02280c7..be9e833 100644
--- a/driver-bab.c
+++ b/driver-bab.c
@@ -314,6 +314,7 @@ struct bab_info {
cgsem_t scan_work;
cgsem_t spi_work;
cgsem_t spi_reply;
+ cgsem_t process_reply;
// TODO: redesign these 2
struct bab_work_reply chip_results[BAB_MAXCHIPS];
@@ -1197,6 +1198,7 @@ static void bab_detect(bool hotplug)
cgsem_init(&(babinfo->scan_work));
cgsem_init(&(babinfo->spi_work));
cgsem_init(&(babinfo->spi_reply));
+ cgsem_init(&(babinfo->process_reply));
mutex_init(&babinfo->did_lock);
mutex_init(&babinfo->nonce_lock);
@@ -1478,6 +1480,9 @@ static bool oknonce(struct thr_info *thr, struct cgpu_info *babcgpu, int chip, u
return false;
}
+// Check at least every ...
+#define BAB_RESULT_DELAY_mS 999
+
// Results checking thread
static void *bab_res(void *userdata)
{
@@ -1500,9 +1505,8 @@ static void *bab_res(void *userdata)
}
while (babcgpu->shutdown == false) {
-// TODO: not polling
if (!oldest_nonce(babinfo, &chip, &nonce, &first_second)) {
- cgsleep_ms(3);
+ cgsem_mswait(&(babinfo->process_reply), BAB_RESULT_DELAY_mS);
continue;
}
@@ -1642,6 +1646,9 @@ static bool bab_do_work(struct cgpu_info *babcgpu)
got_a_nonce = true;
}
+ if (got_a_nonce)
+ cgsem_post(&(babinfo->process_reply));
+
/*
* We only care about this after the first reply we find a nonce
* After that, the value has no more effect