thread-safe atomic operations gcc


in way i work on, i have lot formula follows:



pthread_mutex_lock( &frame->mutex );
frame->variable = variable;
pthread_mutex_unlock( &frame->mutex );


this clearly rubbish cpu cycles center instruction only transposed an atomic store. i know gcc definitely able this, nonetheless i haven't means many support such rudimentary thread-safe atomic operations. i reinstate set formula an atomic operation?



(i know rudimentary stores should theoretically atomic, nonetheless i don't wish have wish optimizer isn't screwing adult atomic-ness during indicate process.)



clarification: i need quite atomic; variables wholly used thread synchronization. is, thread b reads value, checks the correct, the correct, sleeps. even thread updates value thread b doesn't comprehend the updated, isn't problem, given only means thread b sleeps didn't unequivocally need to, wakes up, value correct.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?