changeset 783:ec30705b2104

synch: keep track of whether rwlock is held as reader or writer Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 11 Aug 2019 13:35:45 -0400
parents d83ac58d2500
children 78c359f9eee8
files synch.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/synch.c	Sun Aug 11 12:18:09 2019 -0400
+++ b/synch.c	Sun Aug 11 13:35:45 2019 -0400
@@ -75,6 +75,7 @@
 	struct lock_info *info;
 	struct lock_context where;
 	enum synch_type type;
+	bool rwlock_wr:1;
 };
 
 static __thread struct held_lock held_stack[JEFFPC_LOCK_STACK_DEPTH];
@@ -469,7 +470,8 @@
 }
 
 static void check_unheld_for_lock(struct lock_info *info,
-				  const struct lock_context *where)
+				  const struct lock_context *where,
+				  bool rwlock_wr)
 {
 #ifdef JEFFPC_LOCK_TRACKING
 	struct held_lock *held;
@@ -500,6 +502,7 @@
 	held->info = info;
 	held->where = *where;
 	held->type = info->type;
+	held->rwlock_wr = rwlock_wr;
 #endif
 }
 
@@ -576,7 +579,7 @@
 		print_invalid_call("MXLOCK", where);
 
 	check_magic(&l->info, "acquire", where, SYNCH_TYPE_MUTEX);
-	check_unheld_for_lock(&l->info, where);
+	check_unheld_for_lock(&l->info, where, false);
 }
 
 static void verify_lock_unlock(const struct lock_context *where, struct lock *l)
@@ -622,7 +625,7 @@
 		print_invalid_call("RWLOCK", where);
 
 	check_magic(&l->info, "acquire", where, SYNCH_TYPE_RW);
-	check_unheld_for_lock(&l->info, where);
+	check_unheld_for_lock(&l->info, where, wr);
 }
 
 static void verify_rw_unlock(const struct lock_context *where, struct rwlock *l)