int trace_clientobj = -1;
int trace_cond = -1;
int trace_csw = -1;
- int trace_danger_set = -1;
+ int trace_conflict_set = -1;
int trace_mutex = -1;
int trace_rwlock = -1;
int trace_segment = -1;
else VG_BOOL_CLO(arg, "--trace-clientobj", trace_clientobj)
else VG_BOOL_CLO(arg, "--trace-cond", trace_cond)
else VG_BOOL_CLO(arg, "--trace-csw", trace_csw)
- else VG_BOOL_CLO(arg, "--trace-danger-set", trace_danger_set)
+ else VG_BOOL_CLO(arg, "--trace-conflict-set", trace_conflict_set)
else VG_BOOL_CLO(arg, "--trace-fork-join", s_drd_trace_fork_join)
else VG_BOOL_CLO(arg, "--trace-mutex", trace_mutex)
else VG_BOOL_CLO(arg, "--trace-rwlock", trace_rwlock)
cond_set_trace(trace_cond);
if (trace_csw != -1)
thread_trace_context_switches(trace_csw);
- if (trace_danger_set != -1)
- thread_trace_danger_set(trace_danger_set);
+ if (trace_conflict_set != -1)
+ thread_trace_conflict_set(trace_conflict_set);
if (trace_mutex != -1)
mutex_set_trace(trace_mutex);
if (trace_rwlock != -1)
" --drd-stats=yes|no Print statistics about DRD activity [no].\n"
" --trace-clientobj=yes|no Trace all client object activity [no].\n"
" --trace-csw=yes|no Trace all scheduler context switches [no].\n"
-" --trace-danger-set=yes|no Trace all danger set updates [no].\n"
+" --trace-conflict-set=yes|no Trace all conflict set updates [no].\n"
" --trace-segment=yes|no Trace segment actions [no].\n"
" --trace-suppr=yes|no Trace all address suppression actions [no].\n"
);
// thread_print_all();
if (VG_(clo_verbosity) > 1 || s_drd_print_stats)
{
- ULong update_danger_set_count;
+ ULong update_conflict_set_count;
ULong dsnsc;
ULong dscvc;
- update_danger_set_count
- = thread_get_update_danger_set_count(&dsnsc, &dscvc);
+ update_conflict_set_count
+ = thread_get_update_conflict_set_count(&dsnsc, &dscvc);
VG_(message)(Vg_UserMsg,
" thread: %lld context switches"
- " / %lld updates of the danger set",
+ " / %lld updates of the conflict set",
thread_get_context_switch_count(),
- update_danger_set_count);
+ update_conflict_set_count);
VG_(message)(Vg_UserMsg,
" (%lld new sg + %lld combine vc + %lld csw).",
dsnsc,
dscvc,
- update_danger_set_count - dsnsc - dscvc);
+ update_conflict_set_count - dsnsc - dscvc);
VG_(message)(Vg_UserMsg,
" segments: created %lld segments, max %lld alive,"
" %lld discard points.",
static void thread_append_segment(const DrdThreadId tid,
Segment* const sg);
static void thread_discard_segment(const DrdThreadId tid, Segment* const sg);
-static Bool thread_danger_set_up_to_date(const DrdThreadId tid);
-static void thread_compute_danger_set(struct bitmap** danger_set,
- const DrdThreadId tid);
+static Bool thread_conflict_set_up_to_date(const DrdThreadId tid);
+static void thread_compute_conflict_set(struct bitmap** conflict_set,
+ const DrdThreadId tid);
// Local variables.
static ULong s_context_switch_count;
static ULong s_discard_ordered_segments_count;
-static ULong s_update_danger_set_count;
-static ULong s_danger_set_new_segment_count;
-static ULong s_danger_set_combine_vc_count;
-static ULong s_danger_set_bitmap_creation_count;
-static ULong s_danger_set_bitmap2_creation_count;
+static ULong s_update_conflict_set_count;
+static ULong s_conflict_set_new_segment_count;
+static ULong s_conflict_set_combine_vc_count;
+static ULong s_conflict_set_bitmap_creation_count;
+static ULong s_conflict_set_bitmap2_creation_count;
static ThreadId s_vg_running_tid = VG_INVALID_THREADID;
DrdThreadId s_drd_running_tid = DRD_INVALID_THREADID;
ThreadInfo s_threadinfo[DRD_N_THREADS];
-struct bitmap* s_danger_set;
+struct bitmap* s_conflict_set;
static Bool s_trace_context_switches = False;
-static Bool s_trace_danger_set = False;
+static Bool s_trace_conflict_set = False;
static Bool s_segment_merging = True;
s_trace_context_switches = t;
}
-void thread_trace_danger_set(const Bool t)
+void thread_trace_conflict_set(const Bool t)
{
- s_trace_danger_set = t;
+ s_trace_conflict_set = t;
}
void thread_set_segment_merging(const Bool m)
if (s_threadinfo[tid].detached_posix_thread)
{
/* Once a detached thread has finished, its stack is deallocated and */
- /* should no longer be taken into account when computing the danger set*/
+ /* should no longer be taken into account when computing the conflict set*/
s_threadinfo[tid].stack_min = s_threadinfo[tid].stack_max;
/* For a detached thread, calling pthread_exit() invalidates the */
}
s_vg_running_tid = vg_tid;
s_drd_running_tid = drd_tid;
- thread_compute_danger_set(&s_danger_set, drd_tid);
+ thread_compute_conflict_set(&s_conflict_set, drd_tid);
s_context_switch_count++;
}
/** Every change in the vector clock of a thread may cause segments that
* were previously ordered to this thread to become unordered. Hence,
- * it may be necessary to recalculate the danger set if the vector clock
+ * it may be necessary to recalculate the conflict set if the vector clock
* of the current thread is updated. This function check whether such a
* recalculation is necessary.
*
* appended.
* @param new_sg Pointer to the most recent segment of thread tid.
*/
-static Bool danger_set_update_needed(const DrdThreadId tid,
+static Bool conflict_set_update_needed(const DrdThreadId tid,
const Segment* const new_sg)
{
#if 0
tl_assert(new_sg);
/* If a new segment was added to another thread than the running thread, */
- /* just tell the caller to update the danger set. */
+ /* just tell the caller to update the conflict set. */
if (tid != s_drd_running_tid)
return True;
- /* Always let the caller update the danger set after creation of the */
+ /* Always let the caller update the conflict set after creation of the */
/* first segment. */
old_sg = new_sg->prev;
if (old_sg == 0)
break;
/* If the vector clock of the 2nd the last segment is not ordered */
/* to the vector clock of segment q, and the last segment is, ask */
- /* the caller to update the danger set. */
+ /* the caller to update the conflict set. */
if (! vc_lte(&old_sg->vc, &q->vc))
{
return True;
}
/* If the vector clock of the last segment is not ordered to the */
- /* vector clock of segment q, ask the caller to update the danger */
+ /* vector clock of segment q, ask the caller to update the conflict */
/* set. */
if (! vc_lte(&q->vc, &new_sg->vc) && ! vc_lte(&new_sg->vc, &q->vc))
{
new_sg = sg_new(tid, tid);
thread_append_segment(tid, new_sg);
- if (danger_set_update_needed(tid, new_sg))
+ if (conflict_set_update_needed(tid, new_sg))
{
- thread_compute_danger_set(&s_danger_set, s_drd_running_tid);
- s_danger_set_new_segment_count++;
+ thread_compute_conflict_set(&s_conflict_set, s_drd_running_tid);
+ s_conflict_set_new_segment_count++;
}
else if (tid == s_drd_running_tid)
{
- tl_assert(thread_danger_set_up_to_date(s_drd_running_tid));
+ tl_assert(thread_conflict_set_up_to_date(s_drd_running_tid));
}
thread_discard_ordered_segments();
if (joiner == s_drd_running_tid)
{
- thread_compute_danger_set(&s_danger_set, joiner);
+ thread_compute_conflict_set(&s_conflict_set, joiner);
}
}
tl_assert(s_threadinfo[tid].last);
tl_assert(vc);
vc_combine(&s_threadinfo[tid].last->vc, vc);
- thread_compute_danger_set(&s_danger_set, tid);
+ thread_compute_conflict_set(&s_conflict_set, tid);
thread_discard_ordered_segments();
- s_danger_set_combine_vc_count++;
+ s_conflict_set_combine_vc_count++;
}
/** Call this function whenever a thread is no longer using the memory
}
/* If any other thread had accessed memory in [ a1, a2 [, update the */
- /* danger set. */
+ /* conflict set. */
if (other_user != DRD_INVALID_THREADID
- && bm_has_any_access(s_danger_set, a1, a2))
+ && bm_has_any_access(s_conflict_set, a1, a2))
{
- thread_compute_danger_set(&s_danger_set, thread_get_running_tid());
+ thread_compute_conflict_set(&s_conflict_set, thread_get_running_tid());
}
}
}
}
-/** Verify whether the danger set for thread tid is up to date. Only perform
- * the check if the environment variable DRD_VERIFY_DANGER_SET has been set.
+/** Verify whether the conflict set for thread tid is up to date. Only perform
+ * the check if the environment variable DRD_VERIFY_CONFLICT_SET has been set.
*/
-static Bool thread_danger_set_up_to_date(const DrdThreadId tid)
+static Bool thread_conflict_set_up_to_date(const DrdThreadId tid)
{
- static int do_verify_danger_set = -1;
+ static int do_verify_conflict_set = -1;
Bool result;
- struct bitmap* computed_danger_set = 0;
+ struct bitmap* computed_conflict_set = 0;
- if (do_verify_danger_set < 0)
+ if (do_verify_conflict_set < 0)
{
- //VG_(message)(Vg_DebugMsg, "%s", VG_(getenv)("DRD_VERIFY_DANGER_SET"));
- do_verify_danger_set = VG_(getenv)("DRD_VERIFY_DANGER_SET") != 0;
+ //VG_(message)(Vg_DebugMsg, "%s", VG_(getenv)("DRD_VERIFY_CONFLICT_SET"));
+ do_verify_conflict_set = VG_(getenv)("DRD_VERIFY_CONFLICT_SET") != 0;
}
- if (do_verify_danger_set == 0)
+ if (do_verify_conflict_set == 0)
return True;
- thread_compute_danger_set(&computed_danger_set, tid);
- result = bm_equal(s_danger_set, computed_danger_set);
- bm_delete(computed_danger_set);
+ thread_compute_conflict_set(&computed_conflict_set, tid);
+ result = bm_equal(s_conflict_set, computed_conflict_set);
+ bm_delete(computed_conflict_set);
return result;
}
/** Compute a bitmap that represents the union of all memory accesses of all
* segments that are unordered to the current segment of the thread tid.
*/
-static void thread_compute_danger_set(struct bitmap** danger_set,
- const DrdThreadId tid)
+static void thread_compute_conflict_set(struct bitmap** conflict_set,
+ const DrdThreadId tid)
{
Segment* p;
&& tid != DRD_INVALID_THREADID);
tl_assert(tid == s_drd_running_tid);
- s_update_danger_set_count++;
- s_danger_set_bitmap_creation_count -= bm_get_bitmap_creation_count();
- s_danger_set_bitmap2_creation_count -= bm_get_bitmap2_creation_count();
+ s_update_conflict_set_count++;
+ s_conflict_set_bitmap_creation_count -= bm_get_bitmap_creation_count();
+ s_conflict_set_bitmap2_creation_count -= bm_get_bitmap2_creation_count();
- if (*danger_set)
+ if (*conflict_set)
{
- bm_delete(*danger_set);
+ bm_delete(*conflict_set);
}
- *danger_set = bm_new();
+ *conflict_set = bm_new();
- if (s_trace_danger_set)
+ if (s_trace_conflict_set)
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
- "computing danger set for thread %d/%d with vc ",
+ "computing conflict set for thread %d/%d with vc ",
DrdThreadIdToVgThreadId(tid), tid);
vc_snprint(msg + VG_(strlen)(msg),
sizeof(msg) - VG_(strlen)(msg),
{
unsigned j;
- if (s_trace_danger_set)
+ if (s_trace_conflict_set)
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
- "danger set: thread [%d] at vc ",
+ "conflict set: thread [%d] at vc ",
tid);
vc_snprint(msg + VG_(strlen)(msg),
sizeof(msg) - VG_(strlen)(msg),
{
if (! vc_lte(&q->vc, &p->vc) && ! vc_lte(&p->vc, &q->vc))
{
- if (s_trace_danger_set)
+ if (s_trace_conflict_set)
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
- "danger set: [%d] merging segment ", j);
+ "conflict set: [%d] merging segment ", j);
vc_snprint(msg + VG_(strlen)(msg),
sizeof(msg) - VG_(strlen)(msg),
&q->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
- bm_merge2(*danger_set, q->bm);
+ bm_merge2(*conflict_set, q->bm);
}
else
{
- if (s_trace_danger_set)
+ if (s_trace_conflict_set)
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
- "danger set: [%d] ignoring segment ", j);
+ "conflict set: [%d] ignoring segment ", j);
vc_snprint(msg + VG_(strlen)(msg),
sizeof(msg) - VG_(strlen)(msg),
&q->vc);
}
}
- s_danger_set_bitmap_creation_count += bm_get_bitmap_creation_count();
- s_danger_set_bitmap2_creation_count += bm_get_bitmap2_creation_count();
+ s_conflict_set_bitmap_creation_count += bm_get_bitmap_creation_count();
+ s_conflict_set_bitmap2_creation_count += bm_get_bitmap2_creation_count();
- if (0 && s_trace_danger_set)
+ if (0 && s_trace_conflict_set)
{
- VG_(message)(Vg_UserMsg, "[%d] new danger set:", tid);
- bm_print(*danger_set);
- VG_(message)(Vg_UserMsg, "[%d] end of new danger set.", tid);
+ VG_(message)(Vg_UserMsg, "[%d] new conflict set:", tid);
+ bm_print(*conflict_set);
+ VG_(message)(Vg_UserMsg, "[%d] end of new conflict set.", tid);
}
}
return s_discard_ordered_segments_count;
}
-ULong thread_get_update_danger_set_count(ULong* dsnsc, ULong* dscvc)
+ULong thread_get_update_conflict_set_count(ULong* dsnsc, ULong* dscvc)
{
tl_assert(dsnsc);
tl_assert(dscvc);
- *dsnsc = s_danger_set_new_segment_count;
- *dscvc = s_danger_set_combine_vc_count;
- return s_update_danger_set_count;
+ *dsnsc = s_conflict_set_new_segment_count;
+ *dscvc = s_conflict_set_combine_vc_count;
+ return s_update_conflict_set_count;
}
-ULong thread_get_danger_set_bitmap_creation_count(void)
+ULong thread_get_conflict_set_bitmap_creation_count(void)
{
- return s_danger_set_bitmap_creation_count;
+ return s_conflict_set_bitmap_creation_count;
}
-ULong thread_get_danger_set_bitmap2_creation_count(void)
+ULong thread_get_conflict_set_bitmap2_creation_count(void)
{
- return s_danger_set_bitmap2_creation_count;
+ return s_conflict_set_bitmap2_creation_count;
}
Bool bm_access_load_1_triggers_conflict(const Addr a1)
{
bm_access_load_1(running_thread_get_segment()->bm, a1);
- return bm_load_1_has_conflict_with(thread_get_danger_set(), a1);
+ return bm_load_1_has_conflict_with(thread_get_conflict_set(), a1);
}
static __inline__
if ((a1 & 1) == 0)
{
bm_access_aligned_load(running_thread_get_segment()->bm, a1, 2);
- return bm_aligned_load_has_conflict_with(thread_get_danger_set(), a1, 2);
+ return bm_aligned_load_has_conflict_with(thread_get_conflict_set(), a1, 2);
}
else
{
bm_access_range(running_thread_get_segment()->bm, a1, a1 + 2, eLoad);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 2, eLoad);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 2, eLoad);
}
}
if ((a1 & 3) == 0)
{
bm_access_aligned_load(running_thread_get_segment()->bm, a1, 4);
- return bm_aligned_load_has_conflict_with(thread_get_danger_set(), a1, 4);
+ return bm_aligned_load_has_conflict_with(thread_get_conflict_set(), a1, 4);
}
else
{
bm_access_range(running_thread_get_segment()->bm, a1, a1 + 4, eLoad);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 4, eLoad);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 4, eLoad);
}
}
if ((a1 & 7) == 0)
{
bm_access_aligned_load(running_thread_get_segment()->bm, a1, 8);
- return bm_aligned_load_has_conflict_with(thread_get_danger_set(), a1, 8);
+ return bm_aligned_load_has_conflict_with(thread_get_conflict_set(), a1, 8);
}
else if ((a1 & 3) == 0)
{
bm_access_aligned_load(running_thread_get_segment()->bm, a1 + 0, 4);
bm_access_aligned_load(running_thread_get_segment()->bm, a1 + 4, 4);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eLoad);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eLoad);
}
else
{
bm_access_range(running_thread_get_segment()->bm, a1, a1 + 8, eLoad);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eLoad);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eLoad);
}
}
Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2)
{
bm_access_range_load(running_thread_get_segment()->bm, a1, a2);
- return bm_load_has_conflict_with(thread_get_danger_set(), a1, a2);
+ return bm_load_has_conflict_with(thread_get_conflict_set(), a1, a2);
}
static __inline__
Bool bm_access_store_1_triggers_conflict(const Addr a1)
{
bm_access_store_1(running_thread_get_segment()->bm, a1);
- return bm_store_1_has_conflict_with(thread_get_danger_set(), a1);
+ return bm_store_1_has_conflict_with(thread_get_conflict_set(), a1);
}
static __inline__
if ((a1 & 1) == 0)
{
bm_access_aligned_store(running_thread_get_segment()->bm, a1, 2);
- return bm_aligned_store_has_conflict_with(thread_get_danger_set(), a1, 2);
+ return bm_aligned_store_has_conflict_with(thread_get_conflict_set(), a1, 2);
}
else
{
bm_access_range(running_thread_get_segment()->bm, a1, a1 + 2, eStore);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 2, eStore);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 2, eStore);
}
}
if ((a1 & 3) == 0)
{
bm_access_aligned_store(running_thread_get_segment()->bm, a1, 4);
- return bm_aligned_store_has_conflict_with(thread_get_danger_set(), a1, 4);
+ return bm_aligned_store_has_conflict_with(thread_get_conflict_set(), a1, 4);
}
else
{
bm_access_range(running_thread_get_segment()->bm, a1, a1 + 4, eStore);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 4, eStore);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 4, eStore);
}
}
if ((a1 & 7) == 0)
{
bm_access_aligned_store(running_thread_get_segment()->bm, a1, 8);
- return bm_aligned_store_has_conflict_with(thread_get_danger_set(), a1, 8);
+ return bm_aligned_store_has_conflict_with(thread_get_conflict_set(), a1, 8);
}
else if ((a1 & 3) == 0)
{
bm_access_aligned_store(running_thread_get_segment()->bm, a1 + 0, 4);
bm_access_aligned_store(running_thread_get_segment()->bm, a1 + 4, 4);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eStore);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eStore);
}
else
{
bm_access_range(running_thread_get_segment()->bm, a1, a1 + 8, eStore);
- return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eStore);
+ return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eStore);
}
}
Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2)
{
bm_access_range_store(running_thread_get_segment()->bm, a1, a2);
- return bm_store_has_conflict_with(thread_get_danger_set(), a1, a2);
+ return bm_store_has_conflict_with(thread_get_conflict_set(), a1, a2);
}
#endif // __DRD_THREAD_BITMAP_H