Commit 9604cbee98e6c61b7044fd4234d0c2a9627da6d8

Con Kolivas 2013-06-13T13:59:17

Sleep if the avalon buffer is empty and we've requested a read to allow the write thread to take precedence.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/driver-avalon.c b/driver-avalon.c
index 9deb190..c5c95f8 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -241,6 +241,11 @@ static int avalon_read(struct cgpu_info *avalon, unsigned char *buf,
 	char readbuf[AVALON_READBUF_SIZE];
 	int err, amount, ofs = 2, cp;
 
+	/* If the buffer is ready to take more work, yield once in case the
+	 * write thread is waiting to be scheduled. */
+	if (!avalon_buffer_full(avalon))
+		nmsleep(40);
+
 	err = usb_read_once_timeout(avalon, readbuf, readsize, &amount, timeout, ep);
 	applog(LOG_DEBUG, "%s%i: Get avalon read got err %d",
 	       avalon->drv->name, avalon->device_id, err);