1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-10 23:08:07 +00:00

add lock when accessing mining_threads

This commit is contained in:
Jan Berdajs 2014-06-30 22:12:19 +02:00
parent 028f19e946
commit be7d47dcee

View File

@ -6317,14 +6317,17 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
//get the number of active threads to know when to switch... if we only check total threads, we may wait for ever on a disabled GPU //get the number of active threads to know when to switch... if we only check total threads, we may wait for ever on a disabled GPU
active_threads = 0; active_threads = 0;
rd_lock(&mining_thr_lock);
for(i = 0; i < mining_threads; i++) for(i = 0; i < mining_threads; i++)
{ {
struct thr_info *thr = mining_thr[i]; struct cgpu_info *cgpu = mining_thr[i]->cgpu;
//dont count dead/sick GPU threads or we may wait for ever also... //dont count dead/sick GPU threads or we may wait for ever also...
if(thr->cgpu->deven != DEV_DISABLED && thr->cgpu->status != LIFE_SICK && thr->cgpu->status != LIFE_DEAD) if(cgpu->deven != DEV_DISABLED && cgpu->status != LIFE_SICK && cgpu->status != LIFE_DEAD)
active_threads++; active_threads++;
} }
rd_unlock(&mining_thr_lock);
// If all threads are waiting now // If all threads are waiting now
if(algo_switch_n >= active_threads) if(algo_switch_n >= active_threads)