|
From: <sv...@va...> - 2008-03-30 18:06:05
|
Author: bart
Date: 2008-03-30 18:56:43 +0100 (Sun, 30 Mar 2008)
New Revision: 7824
Log:
Introduced bm_test_and_clear().
Modified:
trunk/exp-drd/drd_bitmap.c
trunk/exp-drd/drd_thread.c
trunk/exp-drd/pub_drd_bitmap.h
Modified: trunk/exp-drd/drd_bitmap.c
===================================================================
--- trunk/exp-drd/drd_bitmap.c 2008-03-30 16:55:40 UTC (rev 7823)
+++ trunk/exp-drd/drd_bitmap.c 2008-03-30 17:56:43 UTC (rev 7824)
@@ -477,6 +477,20 @@
}
}
+/** 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)
Modified: trunk/exp-drd/drd_thread.c
===================================================================
--- trunk/exp-drd/drd_thread.c 2008-03-30 16:55:40 UTC (rev 7823)
+++ trunk/exp-drd/drd_thread.c 2008-03-30 17:56:43 UTC (rev 7824)
@@ -670,10 +670,13 @@
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);
}
Modified: trunk/exp-drd/pub_drd_bitmap.h
===================================================================
--- trunk/exp-drd/pub_drd_bitmap.h 2008-03-30 16:55:40 UTC (rev 7823)
+++ trunk/exp-drd/pub_drd_bitmap.h 2008-03-30 17:56:43 UTC (rev 7824)
@@ -84,6 +84,8 @@
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);
|