|
@@ -189,7 +189,7 @@ pthread_cond_t gws_cond;
|
|
|
double total_mhashes_done;
|
|
double total_mhashes_done;
|
|
|
static struct timeval total_tv_start, total_tv_end;
|
|
static struct timeval total_tv_start, total_tv_end;
|
|
|
|
|
|
|
|
-pthread_mutex_t control_lock;
|
|
|
|
|
|
|
+cglock_t control_lock;
|
|
|
pthread_mutex_t stats_lock;
|
|
pthread_mutex_t stats_lock;
|
|
|
|
|
|
|
|
int hw_errors;
|
|
int hw_errors;
|
|
@@ -468,9 +468,9 @@ struct pool *current_pool(void)
|
|
|
{
|
|
{
|
|
|
struct pool *pool;
|
|
struct pool *pool;
|
|
|
|
|
|
|
|
- mutex_lock(&control_lock);
|
|
|
|
|
|
|
+ cg_rlock(&control_lock);
|
|
|
pool = currentpool;
|
|
pool = currentpool;
|
|
|
- mutex_unlock(&control_lock);
|
|
|
|
|
|
|
+ cg_runlock(&control_lock);
|
|
|
return pool;
|
|
return pool;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1388,9 +1388,9 @@ static struct work *make_work(void)
|
|
|
|
|
|
|
|
if (unlikely(!work))
|
|
if (unlikely(!work))
|
|
|
quit(1, "Failed to calloc work in make_work");
|
|
quit(1, "Failed to calloc work in make_work");
|
|
|
- mutex_lock(&control_lock);
|
|
|
|
|
|
|
+ cg_wlock(&control_lock);
|
|
|
work->id = total_work++;
|
|
work->id = total_work++;
|
|
|
- mutex_unlock(&control_lock);
|
|
|
|
|
|
|
+ cg_wunlock(&control_lock);
|
|
|
return work;
|
|
return work;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2374,12 +2374,12 @@ static uint64_t share_diff(const struct work *work)
|
|
|
if (unlikely(!d64))
|
|
if (unlikely(!d64))
|
|
|
d64 = 1;
|
|
d64 = 1;
|
|
|
ret = diffone / d64;
|
|
ret = diffone / d64;
|
|
|
- mutex_lock(&control_lock);
|
|
|
|
|
|
|
+ cg_wlock(&control_lock);
|
|
|
if (ret > best_diff) {
|
|
if (ret > best_diff) {
|
|
|
best_diff = ret;
|
|
best_diff = ret;
|
|
|
suffix_string(best_diff, best_share, 0);
|
|
suffix_string(best_diff, best_share, 0);
|
|
|
}
|
|
}
|
|
|
- mutex_unlock(&control_lock);
|
|
|
|
|
|
|
+ cg_wunlock(&control_lock);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -3256,7 +3256,7 @@ void switch_pools(struct pool *selected)
|
|
|
struct pool *pool, *last_pool;
|
|
struct pool *pool, *last_pool;
|
|
|
int i, pool_no, next_pool;
|
|
int i, pool_no, next_pool;
|
|
|
|
|
|
|
|
- mutex_lock(&control_lock);
|
|
|
|
|
|
|
+ cg_wlock(&control_lock);
|
|
|
last_pool = currentpool;
|
|
last_pool = currentpool;
|
|
|
pool_no = currentpool->pool_no;
|
|
pool_no = currentpool->pool_no;
|
|
|
|
|
|
|
@@ -3311,7 +3311,7 @@ void switch_pools(struct pool *selected)
|
|
|
|
|
|
|
|
currentpool = pools[pool_no];
|
|
currentpool = pools[pool_no];
|
|
|
pool = currentpool;
|
|
pool = currentpool;
|
|
|
- mutex_unlock(&control_lock);
|
|
|
|
|
|
|
+ cg_wunlock(&control_lock);
|
|
|
|
|
|
|
|
/* Set the lagging flag to avoid pool not providing work fast enough
|
|
/* Set the lagging flag to avoid pool not providing work fast enough
|
|
|
* messages in failover only mode since we have to get all fresh work
|
|
* messages in failover only mode since we have to get all fresh work
|
|
@@ -4987,9 +4987,9 @@ static inline int cp_prio(void)
|
|
|
{
|
|
{
|
|
|
int prio;
|
|
int prio;
|
|
|
|
|
|
|
|
- mutex_lock(&control_lock);
|
|
|
|
|
|
|
+ cg_rlock(&control_lock);
|
|
|
prio = currentpool->prio;
|
|
prio = currentpool->prio;
|
|
|
- mutex_unlock(&control_lock);
|
|
|
|
|
|
|
+ cg_runlock(&control_lock);
|
|
|
return prio;
|
|
return prio;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -6460,7 +6460,7 @@ int main(int argc, char *argv[])
|
|
|
mutex_init(&hash_lock);
|
|
mutex_init(&hash_lock);
|
|
|
mutex_init(&qd_lock);
|
|
mutex_init(&qd_lock);
|
|
|
mutex_init(&console_lock);
|
|
mutex_init(&console_lock);
|
|
|
- mutex_init(&control_lock);
|
|
|
|
|
|
|
+ cglock_init(&control_lock);
|
|
|
mutex_init(&stats_lock);
|
|
mutex_init(&stats_lock);
|
|
|
mutex_init(&sharelog_lock);
|
|
mutex_init(&sharelog_lock);
|
|
|
mutex_init(&ch_lock);
|
|
mutex_init(&ch_lock);
|