int main () { int i; pthread_t t1; pthread_create(&t1, NULL, t_fun, NULL); for(i=0; i<10; i++) cache_entry_addref(&cache[i]); // NOWARN cache[5].refs++; // RACE! return 0; }
int main () { int i; pthread_t t1; pthread_create(&t1, NULL, t_fun, NULL); for(i=0; i<10; i++) cache_entry_addref(&cache[i]); pthread_mutex_lock(&cache[5].refs_mutex); cache[5].refs++; // NOWARN! pthread_mutex_lock(&cache[5].refs_mutex); return 0; }
void *t_fun(void *arg) { int i; for(i=0; i<10; i++) cache_entry_addref(&cache[i]); return NULL; }