Skip to content

Commit

Permalink
Add test for joinign thread array
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schwarz committed Nov 1, 2023
1 parent 6131273 commit 031dde1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/regression/10-synch/28-join-array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// PARAM: --set ana.activated[+] thread
#include <pthread.h>

int data = 0;
pthread_mutex_t data_mutex;

void *thread(void *arg) {
pthread_mutex_lock(&data_mutex);
data = 3; // RACE!
pthread_mutex_unlock(&data_mutex);
return NULL;
}

int main() {
pthread_t tids[2];

pthread_create(&tids[0], NULL, &thread, NULL);
pthread_create(&tids[1], NULL, &thread, NULL);

pthread_join(tids[0], NULL);

data = 1; //RACE!

return 1;
}

0 comments on commit 031dde1

Please sign in to comment.