From: Bart Van Assche Date: Sun, 30 Mar 2008 17:56:43 +0000 (+0000) Subject: Introduced bm_test_and_clear(). X-Git-Tag: svn/VALGRIND_3_4_0~771 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8d4a6c4012966758dad360686eff5fe3a0cc5f58;p=thirdparty%2Fvalgrind.git Introduced bm_test_and_clear(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7824 --- diff --git a/exp-drd/drd_bitmap.c b/exp-drd/drd_bitmap.c index 81424baf6c..03ed89bc60 100644 --- a/exp-drd/drd_bitmap.c +++ b/exp-drd/drd_bitmap.c @@ -477,6 +477,20 @@ void bm_clear_store(const struct bitmap* const bm, } } +/** Clear bitmap bm starting at address a1 and up to but not including address + * a2. Return True if and only if any of the addresses was set before + * clearing. + */ +Bool bm_test_and_clear(const struct bitmap* const bm, + const Addr a1, const Addr a2) +{ + Bool result; + + result = bm_has_any_access(bm, a1, a2) != 0; + bm_clear(bm, a1, a2); + return result; +} + Bool bm_has_conflict_with(const struct bitmap* const bm, const Addr a1, const Addr a2, const BmAccessTypeT access_type) diff --git a/exp-drd/drd_thread.c b/exp-drd/drd_thread.c index 55bf0fd114..b8eb755ad0 100644 --- a/exp-drd/drd_thread.c +++ b/exp-drd/drd_thread.c @@ -670,10 +670,13 @@ void thread_stop_using_mem(const Addr a1, const Addr a2) for (p = s_threadinfo[i].first; p; p = p->next) { if (other_user == DRD_INVALID_THREADID - && i != s_drd_running_tid - && bm_has_any_access(p->bm, a1, a2)) + && i != s_drd_running_tid) { - other_user = i; + if (UNLIKELY(bm_test_and_clear(p->bm, a1, a2))) + { + other_user = i; + } + continue; } bm_clear(p->bm, a1, a2); } diff --git a/exp-drd/pub_drd_bitmap.h b/exp-drd/pub_drd_bitmap.h index ede095e4ce..72470ace0a 100644 --- a/exp-drd/pub_drd_bitmap.h +++ b/exp-drd/pub_drd_bitmap.h @@ -84,6 +84,8 @@ void bm_clear_load(const struct bitmap* const bm, const Addr a1, const Addr a2); void bm_clear_store(const struct bitmap* const bm, const Addr a1, const Addr a2); +Bool bm_test_and_clear(const struct bitmap* const bm, + const Addr a1, const Addr a2); Bool bm_has_conflict_with(const struct bitmap* const bm, const Addr a1, const Addr a2, const BmAccessTypeT access_type);