Michael
Michael

Reputation: 5897

Best way to implement read and write mutexes using pthreads?

I've got a data structure that could be read simultaneously by 100s of threads, but naturally write/write and write/read conflicts must be avoided. My 1st attempt with pthread_mutex_lock prevented multiple reads. What would be a good way, using pthreads, to prevent write/write and write/read while allowing multiple reads?

Upvotes: 2

Views: 51

Answers (1)

pilcrow
pilcrow

Reputation: 58524

A great way would be to use the native rwlock facility from pthreads itself.

Upvotes: 1

Related Questions