Create basic read and write threads that will be used by hashfast driver.
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
diff --git a/driver-hashfast.c b/driver-hashfast.c
index d19e486..f68e2a7 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -324,7 +324,7 @@ static bool hashfast_detect_common(struct cgpu_info *hashfast)
return true;
}
-static void hashfast_usb_initialise(struct cgpu_info *hashfast)
+static void hashfast_initialise(struct cgpu_info *hashfast)
{
if (hashfast->usbinfo.nodev)
return;
@@ -346,7 +346,7 @@ static bool hashfast_detect_one_usb(libusb_device *dev, struct usb_find_devices
hashfast->usbdev->usb_type = USB_TYPE_STD;
- hashfast_usb_initialise(hashfast);
+ hashfast_initialise(hashfast);
add_cgpu(hashfast);
@@ -361,8 +361,42 @@ static void hashfast_detect(bool hotplug)
usb_detect(&hashfast_drv, hashfast_detect_one_usb);
}
-static bool hashfast_prepare(struct thr_info __maybe_unused *thr)
+static void *hf_read(void *arg)
{
+ struct cgpu_info *hashfast = (struct cgpu_info *)arg;
+ struct hashfast_info *info = hashfast->device_data;
+
+ while (likely(!hashfast->shutdown)) {
+
+ }
+ return NULL;
+}
+
+static void *hf_write(void *arg)
+{
+ struct cgpu_info *hashfast = (struct cgpu_info *)arg;
+ struct hashfast_info *info = hashfast->device_data;
+
+ while (likely(!hashfast->shutdown)) {
+
+ }
+ return NULL;
+}
+
+static bool hashfast_prepare(struct thr_info*thr)
+{
+ struct cgpu_info *hashfast = thr->cgpu;
+ struct hashfast_info *info = hashfast->device_data;
+ struct timeval now;
+
+ mutex_init(&info->lock);
+ mutex_init(&info->write_mutex);
+ if (pthread_cond_init(&info->write_cond, NULL))
+ quit(1, "Failed to pthread_cond_init in hashfast_prepare");
+ if (pthread_create(&info->read_thr, NULL, hf_read, (void *)hashfast))
+ quit(1, "Failed to pthread_create read thr in hashfast_prepare");
+ if (pthread_create(&info->write_thr, NULL, hf_write, (void *)hashfast))
+ quit(1, "Failed to pthread_create write thr in hashfast_prepare");
return true;
}
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 4bd89f5..9e7a0cd 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -44,10 +44,16 @@ struct hashfast_info {
int core_bitmap_size; // in bytes
uint32_t *core_bitmap; // Core OK bitmap test results, run with PLL Bypassed
+ pthread_mutex_t lock;
struct work **works;
uint16_t device_sequence_head; // The most recent sequence number the device dispatched
uint16_t device_sequence_tail; // The most recently completed job in the device
uint16_t hash_sequence_tail; // Follows device_sequence_tail around to free work
+
+ pthread_t read_thr;
+ pthread_t write_thr;
+ pthread_mutex_t write_mutex;
+ pthread_cond_t write_cond;
};
#endif /* USE_HASHFAST */