[asterisk-dev] Using pthread_rwlock_t in Asterisk
Kevin P. Fleming
kpfleming at digium.com
Thu Mar 2 12:44:55 MST 2006
Russell Bryant wrote:
> Are there portability, performance, or any other kind of issues that I
> have not come across that would serve as a reason why this project would
> not be a good idea?
There is one big issue: all rwlock implementations have to decide
between reader-priority and writer-priority. There is no alternative, as
long as 'upgrading' a read lock into a write lock is available (the
alternative is to read lock/read/unlock, then write
lock/read/compare/write/unlock, which is expensive).
We don't know what the choice made by the C library we are using was,
and it could conceivably change between major releases (although that
would be unlikely). Given that, the only place that rwlocks can be used
in Asterisk is where the priority would _not_ matter, and that takes
quite a bit of effort to analyze. In addition, it means future code
changes to structures using those rwlocks need to be be thoroughly
understood to ensure that the lock priority would not have a negative
effect on the new code.
In summary: yes, they could be useful, but they come with some concerns
and complexity.
More information about the asterisk-dev
mailing list