Using pthread condition variable with rwlock
Posted
by Doomsday
on Stack Overflow
See other posts from Stack Overflow
or by Doomsday
Published on 2010-04-23T15:53:27Z
Indexed on
2010/04/23
16:33 UTC
Read the original article
Hit count: 180
Hello, I'm looking for a way to use pthread rwlock structure with conditions routines in C++.
I have two questions:
First: How is it possible and if we can't, why ?
Second: Why current POSIX pthread have not implemented this behaviour ?
To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing with one shared array. The consumer will cond_wait when the array is empty, but rdlock when reading some elems. The producer will wrlock when adding(+signal) or removing elems from the array.
The benefit of using rdlock instead of mutex_lock is to improve performance: when using mutex_lock, several readers would block, whereas using rdlock several readers would not block.
© Stack Overflow or respective owner