Browse Source

adding kasserts to ensure locks are owned when being used

tarfeef101 7 years ago
parent
commit
4d25366a59
1 changed files with 2 additions and 0 deletions
  1. 2 0
      kern/thread/synch.c

+ 2 - 0
kern/thread/synch.c

@@ -188,6 +188,7 @@ void lock_destroy(struct lock * lock)
 void lock_acquire(struct lock * lock)
 {
   KASSERT(lock);
+  KASSERT(lock_do_i_hold(lock));
   
   spinlock_acquire(&(lock->spin));
   
@@ -206,6 +207,7 @@ void lock_acquire(struct lock * lock)
 void lock_release(struct lock * lock)
 {
   KASSERT(lock);
+  KASSERT(lock_do_i_hold(lock));
   
   spinlock_acquire(&(lock->spin));
   KASSERT(curthread == lock->owner);