While I was looking at the pthread_rwlock_unlock function man page, I noticed that func will return EPERM if the calling thread does not have ownership of rwlock.
Because rdlock allows multiple threads to receive a lock, there must be a data structure, such as a reference or array, to hold the owner of one particular rwlock.
The question arises:
Rwlock is designed to achieve efficiency when a read operation is much more common than a write operation, but if there are a large number of different threads that have received a read lock, each time I call pthread_rwlock_unlock (), it takes time to find this means that the calling thread is a valid owner. what is the time complexity of this scenario.
Thanks a lot guys :)
source
share