|
From: Konstantin S. <kon...@gm...> - 2010-01-27 14:17:55
|
On Wed, Jan 27, 2010 at 3:41 PM, Julian Seward <js...@ac...> wrote: > > Konstantin, > > I'm trying to annotate a user-implemented barrier, using > > > http://code.google.com/p/google-perftools/source/browse/trunk/src/base/dynamic_annotations.h > specifically ANNOTATE_HAPPENS_BEFORE and ANNOTATE_HAPPENS_AFTER > > like this > > void barrier_wait ( barrier* b ) > { > ANNOTATE_HAPPENS_BEFORE(b); > // the barrier implementation > ANNOTATE_HAPPENS_AFTER(b); > } > this is exactly how I handle barrier. > > But this doesn't work well, and I think it's not clear what semantics > you intended for these two. > > This situation I can understand: > > T1: AH_BEFORE(obj) > T2: AH_AFTER(obj) > > then we get an edge T1->T2 > > But what about this? > > T1: AH_BEFORE(obj) > T2: AH_BEFORE(obj) > T3: AH_AFTER(obj) > > Should we get edges T1->T3 and T2->T3, Yes, we will get two edges. The h-before events are never forgotten. (ThreadSanitizer forgets them when it flushes the entire state) > or only T2->T3 ? IOW, does > a call AH_BEFORE(obj) cause obj to "forget" about any previous > AH_BEFORE calls on it? > > It seems to me that to annotate a barrier properly requires generating > two edges in this example, not just one. (Plus then it requires > a way to tell obj to "forget everything" when the barrier is reinitialised, > so that subsequent uses of it do not end up generating edges back to > previous uses.) > That would be possible by adding yet another annotation (ANNOTATE_FORGET_HB_EDGES(obj)) but I never found this really useful, at least in ThreadSanitizer. --kcc > > J > |