|
From: <sv...@va...> - 2009-05-23 18:59:08
|
Author: bart
Date: 2009-05-23 19:58:58 +0100 (Sat, 23 May 2009)
New Revision: 10124
Log:
Added DRD_(thread_update_cs_after_sync)().
Modified:
branches/DRDDEV/drd/drd_barrier.c
branches/DRDDEV/drd/drd_rwlock.c
branches/DRDDEV/drd/drd_thread.c
branches/DRDDEV/drd/drd_thread.h
Modified: branches/DRDDEV/drd/drd_barrier.c
===================================================================
--- branches/DRDDEV/drd/drd_barrier.c 2009-05-23 18:40:39 UTC (rev 10123)
+++ branches/DRDDEV/drd/drd_barrier.c 2009-05-23 18:58:58 UTC (rev 10124)
@@ -460,14 +460,22 @@
* Combine all vector clocks that were stored in the pre_barrier_wait
* wrapper with the vector clock of the current thread.
*/
- VG_(OSetGen_ResetIter)(p->oset);
- for ( ; (r = VG_(OSetGen_Next)(p->oset)) != 0; )
{
- if (r != q)
+ VectorClock old_vc;
+
+ DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc);
+ VG_(OSetGen_ResetIter)(p->oset);
+ for ( ; (r = VG_(OSetGen_Next)(p->oset)) != 0; )
{
- tl_assert(r->sg[p->post_iteration]);
- DRD_(thread_combine_vc_sync)(tid, r->sg[p->post_iteration]);
+ if (r != q)
+ {
+ tl_assert(r->sg[p->post_iteration]);
+ DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc,
+ &r->sg[p->post_iteration]->vc);
+ }
}
+ DRD_(thread_update_cs_after_sync)(tid, &old_vc);
+ DRD_(vc_cleanup)(&old_vc);
}
/* Create a new segment and store a pointer to that segment. */
Modified: branches/DRDDEV/drd/drd_rwlock.c
===================================================================
--- branches/DRDDEV/drd/drd_rwlock.c 2009-05-23 18:40:39 UTC (rev 10123)
+++ branches/DRDDEV/drd/drd_rwlock.c 2009-05-23 18:58:58 UTC (rev 10124)
@@ -168,15 +168,20 @@
const Bool readers_too)
{
struct rwlock_thread_info* q;
+ VectorClock old_vc;
+ DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc);
VG_(OSetGen_ResetIter)(p->thread_info);
for ( ; (q = VG_(OSetGen_Next)(p->thread_info)) != 0; )
{
if (q->tid != tid && (readers_too || q->last_lock_was_writer_lock))
{
- DRD_(thread_combine_vc_sync)(tid, q->last_unlock_segment);
+ DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc,
+ &q->last_unlock_segment->vc);
}
}
+ DRD_(thread_update_cs_after_sync)(tid, &old_vc);
+ DRD_(vc_cleanup)(&old_vc);
}
/** Initialize the rwlock_info data structure *p. */
Modified: branches/DRDDEV/drd/drd_thread.c
===================================================================
--- branches/DRDDEV/drd/drd_thread.c 2009-05-23 18:40:39 UTC (rev 10123)
+++ branches/DRDDEV/drd/drd_thread.c 2009-05-23 18:58:58 UTC (rev 10124)
@@ -713,7 +713,7 @@
* clock of all threads -- these segments can no longer be involved in a
* data race.
*/
-static void DRD_(thread_discard_ordered_segments)(void)
+static void thread_discard_ordered_segments(void)
{
unsigned i;
VectorClock thread_vc_min;
@@ -959,7 +959,7 @@
tl_assert(thread_conflict_set_up_to_date(DRD_(g_drd_running_tid)));
}
- DRD_(thread_discard_ordered_segments)();
+ thread_discard_ordered_segments();
if (s_segment_merging
&& ++s_new_segments_since_last_merge >= s_segment_merge_interval)
@@ -980,7 +980,7 @@
tl_assert(DRD_(g_threadinfo)[joinee].last);
DRD_(vc_combine)(&DRD_(g_threadinfo)[joiner].last->vc,
&DRD_(g_threadinfo)[joinee].last->vc);
- DRD_(thread_discard_ordered_segments)();
+ thread_discard_ordered_segments();
if (joiner == DRD_(g_drd_running_tid))
{
@@ -1010,14 +1010,8 @@
DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc);
DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, vc);
- if (conflict_set_update_needed(tid, &old_vc,
- &DRD_(g_threadinfo)[tid].last->vc))
- {
- thread_compute_conflict_set(&DRD_(g_conflict_set), tid);
- s_conflict_set_combine_vc_count++;
- }
+ DRD_(thread_update_cs_after_sync)(tid, &old_vc);
DRD_(vc_cleanup)(&old_vc);
- DRD_(thread_discard_ordered_segments)();
}
else
{
@@ -1026,6 +1020,26 @@
}
/**
+ * Update the conflict set after the vector clock of thread tid has been updated
+ * from old_vc to DRD_(g_threadinfo)[tid].last->vc.
+ */
+void DRD_(thread_update_cs_after_sync)(DrdThreadId tid, VectorClock* old_vc)
+{
+ tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
+ && tid != DRD_INVALID_THREADID);
+ tl_assert(old_vc);
+
+ thread_discard_ordered_segments();
+
+ if (conflict_set_update_needed(tid, old_vc,
+ &DRD_(g_threadinfo)[tid].last->vc))
+ {
+ thread_compute_conflict_set(&DRD_(g_conflict_set), tid);
+ s_conflict_set_combine_vc_count++;
+ }
+}
+
+/**
* Call this function whenever a thread is no longer using the memory
* [ a1, a2 [, e.g. because of a call to free() or a stack pointer
* increase.
Modified: branches/DRDDEV/drd/drd_thread.h
===================================================================
--- branches/DRDDEV/drd/drd_thread.h 2009-05-23 18:40:39 UTC (rev 10123)
+++ branches/DRDDEV/drd/drd_thread.h 2009-05-23 18:58:58 UTC (rev 10124)
@@ -150,6 +150,7 @@
void DRD_(thread_combine_vc_join)(const DrdThreadId joiner,
const DrdThreadId joinee);
void DRD_(thread_combine_vc_sync)(const DrdThreadId tid, const Segment* sg);
+void DRD_(thread_update_cs_after_sync)(DrdThreadId tid, VectorClock* old_vc);
void DRD_(thread_stop_using_mem)(const Addr a1, const Addr a2);
void DRD_(thread_start_recording)(const DrdThreadId tid);
|