Comment by
crazyboy...@gmail.com:
sorry, i'm a little stupid. i still don't understand how to use dynamic
annotations and how dynamic annotations word. Could someone be so nice to
explain it to me in detail please?
take pthread_cond_wait loop for example:
Mutex mu;
CondVar cv;
// In this example, a false data race on 'GLOB' may be reported if we don't
// insert ANNOTATE_CONDVAR_LOCK_WAIT(&cv, &mu);
void Thread1() {
GLOB = 1; // Access1
mu.Lock();
COND = 1;
cv.Signal(); // <<<<<<<<<<<<<<<<< Does ANNOTATE_CONDVAR_SIGNAL(&cv)
mu.Unlock();
}
void Thread2() {
mu.Lock();
while(COND != 1)
cv.Wait(&mu);
// W/o this annotation the race detector may report
// a false race between Access1 and Access2
// This annotation should be placed rigth after the while loop
ANNOTATE_CONDVAR_LOCK_WAIT(&cv, &mu); // <<<<<<< Matches SIGNAL in
Thread1()
mu.Unlock();
GLOB = 2; // Access2
}
what's the ANNOTATES mean here?