Skip to content

Commit 61cdb71

Browse files
committed
descendant lockset tests involving multiple mutexes
1 parent 8f46eb3 commit 61cdb71

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// PARAM: --set ana.activated[+] threadJoins --set ana.activated[+] threadDescendants --set ana.activated[+] mustlockHistory --set ana.activated[+] descendantLockset
2+
#include <pthread.h>
3+
4+
int global = 0;
5+
pthread_mutex_t mutex1, mutex2 = PTHREAD_MUTEX_INITIALIZER;
6+
pthread_t id1;
7+
8+
void *t1(void *arg) {
9+
pthread_mutex_lock(&mutex1);
10+
pthread_mutex_unlock(&mutex1);
11+
global++; // NORACE
12+
return NULL;
13+
}
14+
15+
int main(void) {
16+
pthread_mutex_lock(&mutex1);
17+
pthread_mutex_lock(&mutex2);
18+
pthread_create(&id1, NULL, t1, NULL);
19+
pthread_mutex_unlock(&mutex2);
20+
global++; // NORACE
21+
return 0;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// PARAM: --set ana.activated[+] threadJoins --set ana.activated[+] threadDescendants --set ana.activated[+] mustlockHistory --set ana.activated[+] descendantLockset
2+
#include <pthread.h>
3+
4+
int global = 0;
5+
pthread_mutex_t mutex1, mutex2 = PTHREAD_MUTEX_INITIALIZER;
6+
pthread_t id1;
7+
8+
void *t1(void *arg) {
9+
pthread_mutex_lock(&mutex1);
10+
pthread_mutex_unlock(&mutex1);
11+
global++; // RACE!
12+
return NULL;
13+
}
14+
15+
int main(void) {
16+
pthread_mutex_lock(&mutex1);
17+
pthread_mutex_lock(&mutex2);
18+
pthread_create(&id1, NULL, t1, NULL);
19+
pthread_mutex_unlock(&mutex1);
20+
global++; // RACE!
21+
return 0;
22+
}

0 commit comments

Comments
 (0)