Yep, that's it.
On Dec 13, 2007 12:30 PM, Julian Seward <[EMAIL PROTECTED]> wrote:
>
> I believe this to be a limitation of the Eraser algorithm. See
> last para of Section 2.2 of
> http://citeseer.ist.psu.edu/savage97eraser.html,
> "Our support for initialization ..."
>
> J
>
>
> On Thursday 13 December 2007 09:12, Konstantin Serebryany wrote:
> > Julian, all, any ideas on this?
> > [ I am sorry for disturbing you... But just in case you've missed this
> > message...]
> >
> > --kcc
> >
> > On Dec 6, 2007 12:23 PM, Konstantin Serebryany
> > <[EMAIL PROTECTED]>
> >
> > wrote:
> > > Hi
> > > One more question:
> > >
> > >
> > > % cat missed_race.cc
> > > #include <pthread.h>
> > > #include <stdio.h>
> > > #include <unistd.h>
> > > // In this test we do the following:
> > > // parent...........................worker
> > > // 1. pthread_create(worker) a. sleep(sleep_worker)
> > > // 2. sleep(sleep_parent) b. print(GLOB)
> > > // 3. GLOB = 1
> > >
> > > // The behaviour of helgrind depends on values of
> > > // sleep_parent/sleep_worker.
> > > // If the values are close (sleep_parent=1000, sleep_worker=2000),
> > > // detection of the race actually depends on luck.
> > > // On my system it is detected 1 of 4-5 of times.
> > > //
> > > // If the parent gets to 'GLOB=1' first, then no race is detected.
> > > // We have Exclusive(parent)->ShR(parent,worker)
> > > //
> > > // If the worker gets to print(GLOB) first, then the race is reported.
> > > // We have Exclusive(worked)->ShM({parent,worker}, {empty lockset})
> > > //
> > > // This race should (IMHO) be detected independently of sleep values.
> > > // Do we need to have ExclusiveR and ExclusiveW instead of just
> > > Exclusive?
> > >
> > > int GLOB = 0;
> > > const int sleep_parent=1000;
> > > const int sleep_worker=2000;
> > >
> > > void *worker(void*)
> > > {
> > > usleep(sleep_worker);
> > > printf("GLOB=%d\n", GLOB);
> > > return NULL;
> > > }
> > > int main(int argc, char **argv)
> > > {
> > > pthread_t threadid;
> > > pthread_create(&threadid, NULL, worker, NULL);
> > > usleep(sleep_parent);
> > > GLOB = 1;
> > > pthread_join(threadid, NULL);
> > > }
> > >
> > > /*
> > > % g++ -g missed_race.cc -lpthread
> > > % for((i=1; i <= 10; i++)); do echo ---------- $i;
> > > ~/race/valgrind32orig/Inst/bin/valgrind -q --tool=helgrind ./a.out
> 2>&1
> > > | grep -A 5 Possible; done
> > > ---------- 1
> > > ---------- 2
> > > ---------- 3
> > > ---------- 4
> > > ---------- 5
> > > ---------- 6
> > > ==13246== Possible data race during write of size 4 at 0x8049850
> > > ==13246== at 0x8048585: main (missed_race.cc:40)
> > > ==13246== Old state: owned exclusively by thread #2
> > > ==13246== New state: shared-modified by threads #1, #2
> > > ==13246== Reason: this thread, #1, holds no locks at all
> > > GLOB=0
> > > ---------- 7
> > > ---------- 8
> > > ==13254== Possible data race during write of size 4 at 0x8049850
> > > ==13254== at 0x8048585: main (missed_race.cc:40)
> > > ==13254== Old state: owned exclusively by thread #2
> > > ==13254== New state: shared-modified by threads #1, #2
> > > ==13254== Reason: this thread, #1, holds no locks at all
> > > GLOB=0
> > > ---------- 9
> > > ---------- 10
> > > %
> > > */
>
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers