From 839db77b7b8c74a9a1c844e82bc30b9a8022908f Mon Sep 17 00:00:00 2001 From: Paul Pluzhnikov Date: Fri, 25 Sep 2009 09:38:55 -0700 Subject: [PATCH] Wait if there is contention on the cache The behavior on wait vs abort unwind depends on the locking primitive chosen by the user. This makes the API consistent and independent of the locking primitive. --- include/dwarf.h | 4 ---- src/dwarf/Gparser.c | 18 ------------------ 2 files changed, 22 deletions(-) diff --git a/include/dwarf.h b/include/dwarf.h index c7c757ed..37b5ec1c 100644 --- a/include/dwarf.h +++ b/include/dwarf.h @@ -312,11 +312,7 @@ typedef unsigned char unw_hash_index_t; struct dwarf_rs_cache { -#ifdef HAVE_ATOMIC_OPS_H - AO_TS_t busy; /* is the rs-cache busy? */ -#else pthread_mutex_t lock; -#endif unsigned short lru_head; /* index of lead-recently used rs */ unsigned short lru_tail; /* index of most-recently used rs */ diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c index 3969cb3a..1e37b5ba 100644 --- a/src/dwarf/Gparser.c +++ b/src/dwarf/Gparser.c @@ -481,21 +481,11 @@ get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp) if (caching == UNW_CACHE_NONE) return NULL; -#ifdef HAVE_ATOMIC_H - if (!spin_trylock_irqsave (&cache->busy, *saved_maskp)) - return NULL; -#else -# ifdef HAVE_ATOMIC_OPS_H - if (AO_test_and_set (&cache->busy) == AO_TS_SET) - return NULL; -# else if (likely (caching == UNW_CACHE_GLOBAL)) { Debug (16, "%s: acquiring lock\n", __FUNCTION__); lock_acquire (&cache->lock, *saved_maskp); } -# endif -#endif if (atomic_read (&as->cache_generation) != atomic_read (&cache->generation)) { @@ -513,16 +503,8 @@ put_rs_cache (unw_addr_space_t as, struct dwarf_rs_cache *cache, assert (as->caching_policy != UNW_CACHE_NONE); Debug (16, "unmasking signals/interrupts and releasing lock\n"); -#ifdef HAVE_ATOMIC_H - spin_unlock_irqrestore (&cache->busy, *saved_maskp); -#else -# ifdef HAVE_ATOMIC_OPS_H - AO_CLEAR (&cache->busy); -# else if (likely (as->caching_policy == UNW_CACHE_GLOBAL)) lock_release (&cache->lock, *saved_maskp); -# endif -#endif } static inline unw_hash_index_t