Get rid of the stage thread since all work can be asynchronously added now via hash_push anyway.
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
diff --git a/cgminer.c b/cgminer.c
index e5cccc7..f47141a 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -196,7 +196,6 @@ bool opt_bfl_noncerange;
struct thr_info *control_thr;
struct thr_info **mining_thr;
static int gwsched_thr_id;
-static int stage_thr_id;
static int watchpool_thr_id;
static int watchdog_thr_id;
#ifdef HAVE_CURSES
@@ -3301,11 +3300,7 @@ static void __kill_work(void)
cg_completion_timeout(&kill_mining, NULL, 3000);
- forcelog(LOG_DEBUG, "Killing off stage thread");
/* Stop the others */
- thr = &control_thr[stage_thr_id];
- kill_timeout(thr);
-
forcelog(LOG_DEBUG, "Killing off API thread");
thr = &control_thr[api_thr_id];
kill_timeout(thr);
@@ -4250,42 +4245,6 @@ static bool hash_push(struct work *work)
return rc;
}
-static void *stage_thread(void *userdata)
-{
- struct thr_info *mythr = userdata;
- bool ok = true;
-
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
-
- RenameThread("stage");
-
- while (ok) {
- struct work *work = NULL;
-
- applog(LOG_DEBUG, "Popping work to stage thread");
-
- work = tq_pop(mythr->q, NULL);
- if (unlikely(!work)) {
- applog(LOG_ERR, "Failed to tq_pop in stage_thread");
- ok = false;
- break;
- }
- work->work_block = work_block;
-
- test_work_current(work);
-
- applog(LOG_DEBUG, "Pushing work to getwork queue");
-
- if (unlikely(!hash_push(work))) {
- applog(LOG_WARNING, "Failed to hash_push in stage_thread");
- continue;
- }
- }
-
- tq_freeze(mythr->q);
- return NULL;
-}
-
static void stage_work(struct work *work)
{
applog(LOG_DEBUG, "Pushing work from pool %d to hash queue", work->pool->pool_no);
@@ -5855,7 +5814,7 @@ retry_stratum:
calc_diff(work, 0);
applog(LOG_DEBUG, "Pushing pooltest work to base pool");
- tq_push(control_thr[stage_thr_id].q, work);
+ stage_work(work);
total_getworks++;
pool->getwork_requested++;
ret = true;
@@ -8166,7 +8125,7 @@ int main(int argc, char *argv[])
if (opt_scantime < 0)
opt_scantime = opt_scrypt ? 30 : 60;
- total_control_threads = 9;
+ total_control_threads = 8;
control_thr = calloc(total_control_threads, sizeof(*thr));
if (!control_thr)
quit(1, "Failed to calloc control_thr");
@@ -8300,16 +8259,6 @@ int main(int argc, char *argv[])
quit(1, "Failed to calloc mining_thr[%d]", i);
}
- stage_thr_id = 2;
- thr = &control_thr[stage_thr_id];
- thr->q = tq_new();
- if (!thr->q)
- quit(1, "Failed to tq_new");
- /* start stage thread */
- if (thr_info_create(thr, NULL, stage_thread, thr))
- quit(1, "stage thread create failed");
- pthread_detach(thr->pth);
-
/* Create a unique get work queue */
getq = tq_new();
if (!getq)
@@ -8414,14 +8363,14 @@ begin_bench:
cgtime(&total_tv_start);
cgtime(&total_tv_end);
- watchpool_thr_id = 3;
+ watchpool_thr_id = 2;
thr = &control_thr[watchpool_thr_id];
/* start watchpool thread */
if (thr_info_create(thr, NULL, watchpool_thread, NULL))
quit(1, "watchpool thread create failed");
pthread_detach(thr->pth);
- watchdog_thr_id = 4;
+ watchdog_thr_id = 3;
thr = &control_thr[watchdog_thr_id];
/* start watchdog thread */
if (thr_info_create(thr, NULL, watchdog_thread, NULL))
@@ -8430,7 +8379,7 @@ begin_bench:
#ifdef HAVE_OPENCL
/* Create reinit gpu thread */
- gpur_thr_id = 5;
+ gpur_thr_id = 4;
thr = &control_thr[gpur_thr_id];
thr->q = tq_new();
if (!thr->q)
@@ -8440,14 +8389,14 @@ begin_bench:
#endif
/* Create API socket thread */
- api_thr_id = 6;
+ api_thr_id = 5;
thr = &control_thr[api_thr_id];
if (thr_info_create(thr, NULL, api_thread, thr))
quit(1, "API thread create failed");
#ifdef USE_USBUTILS
if (!opt_scrypt) {
- hotplug_thr_id = 7;
+ hotplug_thr_id = 6;
thr = &control_thr[hotplug_thr_id];
if (thr_info_create(thr, NULL, hotplug_thread, thr))
quit(1, "hotplug thread create failed");
@@ -8459,7 +8408,7 @@ begin_bench:
/* Create curses input thread for keyboard input. Create this last so
* that we know all threads are created since this can call kill_work
* to try and shut down all previous threads. */
- input_thr_id = 8;
+ input_thr_id = 7;
thr = &control_thr[input_thr_id];
if (thr_info_create(thr, NULL, input_thread, thr))
quit(1, "input thread create failed");
@@ -8467,8 +8416,8 @@ begin_bench:
#endif
/* Just to be sure */
- if (total_control_threads != 9)
- quit(1, "incorrect total_control_threads (%d) should be 9", total_control_threads);
+ if (total_control_threads != 8)
+ quit(1, "incorrect total_control_threads (%d) should be 8", total_control_threads);
/* Once everything is set up, main() becomes the getwork scheduler */
while (42) {