linux thread synchronization

后端 未结 5 946
北海茫月
北海茫月 2021-02-06 14:52

I am new to linux and linux threads. I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. I sti

5条回答
  •  感情败类
    2021-02-06 15:37

    Thanks to all who answered. We resorted to using gcc atomic operations to synchronize all of our threads. The atomic ops were about 2x slower than setting a value without synchronization, but magnitudes faster than locking a mutex, changeing the value, and then unlocking the mutex (this becomes super slow when you start having threads bang into the locks...) We only use pthread_create, attr, cancel, and kill. We use pthread_kill to signal threads to wake up that we put to sleep. This method is 40x faster than cond_wait. So basicly....use pthreads_mutexes if you have time to waste.

提交回复
热议问题