rwlock: fix deadlock condition
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
4c0c5ea592
commit
913b91189b
1 changed files with 4 additions and 1 deletions
|
|
@ -5,8 +5,11 @@ void read_lock(rwlock_t *lock)
|
||||||
{
|
{
|
||||||
spinlock_acquire(&lock->reader_lock);
|
spinlock_acquire(&lock->reader_lock);
|
||||||
|
|
||||||
if (lock->reader_count == 0)
|
if (lock->reader_count == 0) {
|
||||||
|
spinlock_release(&lock->reader_lock);
|
||||||
sem_wait(&lock->sem);
|
sem_wait(&lock->sem);
|
||||||
|
spinlock_acquire(&lock->reader_lock);
|
||||||
|
}
|
||||||
|
|
||||||
lock->reader_count += 1;
|
lock->reader_count += 1;
|
||||||
spinlock_release(&lock->reader_lock);
|
spinlock_release(&lock->reader_lock);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue