From 390d77a2026e30f9c70b9c143a418d04fa69a2fa Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 6 Jul 2012 10:41:08 +1000 Subject: [PATCH] Add more comments explaining how sleep time equals wait time and simplify the comparison. --- driver-bitforce.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/driver-bitforce.c b/driver-bitforce.c index 914a07f5..a13d8623 100644 --- a/driver-bitforce.c +++ b/driver-bitforce.c @@ -368,12 +368,14 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work) if (!pdevbuf[0]) /* Only return if we got nothing after timeout - there still may be results */ return 1; } else if (!strncasecmp(pdevbuf, "N", 1)) {/* Hashing complete (NONCE-FOUND or NO-NONCE) */ - /* Simple timing adjustment */ + /* Simple timing adjustment. Allow a few polls to cope with + * OS timer delays being variably reliable. wait_ms will + * always equal sleep_ms when we've waited greater than or + * equal to the result return time.*/ delay_time_ms = bitforce->sleep_ms; if (bitforce->wait_ms > bitforce->sleep_ms + (WORK_CHECK_INTERVAL_MS * 2)) bitforce->sleep_ms += (bitforce->wait_ms - bitforce->sleep_ms) / 2; - else if (bitforce->wait_ms > bitforce->sleep_ms - WORK_CHECK_INTERVAL_MS && - bitforce->wait_ms <= bitforce->sleep_ms) + else if (bitforce->wait_ms == bitforce->sleep_ms) bitforce->sleep_ms -= BITFORCE_CHECK_INTERVAL_MS; if (delay_time_ms != bitforce->sleep_ms)