Date: Tue, 17 Jul 2012 15:49:36 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r239498 - in soc2012/gmiller/locking-head: . include lib/libwitness Message-ID: <20120717154936.09B851065677@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gmiller Date: Tue Jul 17 15:49:35 2012 New Revision: 239498 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239498 Log: r239511@FreeBSD-dev: root | 2012-07-14 14:00:40 -0500 Implement pthread_lockorder_set_np() and partially implement pthread_lockorder_bless_np(). Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/include/pthread_np.h Tue Jul 17 15:49:35 2012 (r239498) @@ -107,8 +107,8 @@ int pthread_lor_next_np(struct pthread_lor_np *); void pthread_lor_end_np(struct pthread_lor_np *); void pthread_lor_clear_np(void); -void pthread_lockorder_bless_np(void *, void *); -void pthread_lockorder_set_np(void *first, void *second); +int pthread_lockorder_bless_np(void *, void *); +int pthread_lockorder_set_np(void *first, void *second); void pthread_lockorder_reset_np(void); void pthread_lockorder_begin_np(struct pthread_lockorder_np *); int pthread_lockorder_next_np(struct pthread_lockorder_np *); Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Jul 17 15:49:35 2012 (r239498) @@ -47,6 +47,7 @@ info->lock = lock; info->child = NULL; info->sibling = NULL; + SLIST_INIT(&info->bless_head); SLIST_INSERT_HEAD(&lock_info_head, info, lock_info_next); } Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 17 15:49:35 2012 (r239498) @@ -32,12 +32,18 @@ #include <pthread_np.h> #include <stdlib.h> +struct blessing { + SLIST_ENTRY(blessing) bless_next; + struct lock_info *lock; +}; + struct lock_info { SLIST_ENTRY(lock_info) lock_info_next; void *lock; int active; struct lock_info *child; struct lock_info *sibling; + SLIST_HEAD(bless_head, blessing) bless_head; }; extern pthread_mutex_t witness_mtx; Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 17 15:49:35 2012 (r239498) @@ -262,3 +262,35 @@ return (0); } + +int +pthread_lockorder_bless_np(void *first_addr, void *second_addr) +{ + struct lock_info *first; + struct lock_info *second; + struct blessing *first_bless; + struct blessing *second_bless = NULL; + + first = lookup_lock(first_addr); + second = lookup_lock(second_addr); + + first_bless = malloc(sizeof(struct blessing)); + if (first_bless != NULL) { + second_bless = malloc(sizeof(struct blessing)); + if (second_bless == NULL) { + free(first_bless); + } + } + + if (second_bless == NULL) { + return (ENOMEM); + } + + first_bless->lock = second; + SLIST_INSERT_HEAD(&first->bless_head, first_bless, bless_next); + + second_bless->lock = first; + SLIST_INSERT_HEAD(&second->bless_head, second_bless, bless_next); + + return (0); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120717154936.09B851065677>