-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
041e544
commit db320ae
Showing
5 changed files
with
150 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// PARAM: --set ana.activated[+] 'pthreadBarriers' | ||
#include<pthread.h> | ||
#include<stdio.h> | ||
#include<unistd.h> | ||
|
||
int g; | ||
|
||
pthread_barrier_t barrier; | ||
|
||
|
||
void* f1(void* ptr) { | ||
pthread_barrier_wait(&barrier); | ||
return NULL; | ||
} | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int top; | ||
int i = 0; | ||
|
||
pthread_barrier_init(&barrier, NULL, 2); | ||
|
||
pthread_t t1; | ||
pthread_create(&t1,NULL,f1,NULL); | ||
|
||
if(top) { | ||
pthread_barrier_wait(&barrier); | ||
// Live! | ||
i = 1; | ||
} | ||
|
||
__goblint_check(i == 0); //UNKNOWN! | ||
|
||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// PARAM: --set ana.activated[+] 'pthreadBarriers' | ||
#include<pthread.h> | ||
#include<stdio.h> | ||
#include<unistd.h> | ||
|
||
int g; | ||
|
||
pthread_barrier_t barrier; | ||
|
||
void* f2(void* ptr) { | ||
pthread_barrier_wait(&barrier); | ||
return NULL; | ||
} | ||
|
||
void* f1(void* ptr) { | ||
pthread_barrier_wait(&barrier); | ||
|
||
// This is past the barrier, so it will not be reached | ||
pthread_t t2; | ||
pthread_create(&t2,NULL,f2,NULL); | ||
|
||
return NULL; | ||
} | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int top; | ||
int i = 0; | ||
|
||
pthread_barrier_init(&barrier, NULL, 3); | ||
|
||
pthread_t t1; | ||
pthread_create(&t1,NULL,f1,NULL); | ||
|
||
if(top) { | ||
pthread_barrier_wait(&barrier); | ||
// Unreachable | ||
i = 1; | ||
} | ||
|
||
// Created too late to have any effect | ||
pthread_t t2; | ||
pthread_create(&t2,NULL,f1,NULL); | ||
|
||
__goblint_check(i == 0); | ||
|
||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// PARAM: --set ana.activated[+] 'pthreadBarriers' | ||
#include<pthread.h> | ||
#include<stdio.h> | ||
#include<unistd.h> | ||
|
||
int g; | ||
|
||
pthread_barrier_t barrier; | ||
|
||
|
||
void* f1(void* ptr) { | ||
pthread_barrier_wait(&barrier); | ||
|
||
// This should not be reached as either main calls wait or the other thread is created | ||
// -> In the concrete, there never are three threads calling wait | ||
|
||
return NULL; | ||
} | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int top; | ||
int top2; | ||
int i = 0; | ||
|
||
pthread_barrier_init(&barrier, NULL, 3); | ||
|
||
pthread_t t1; | ||
pthread_create(&t1,NULL,f1,NULL); | ||
|
||
if(top) { | ||
pthread_barrier_wait(&barrier); | ||
// Unreachable | ||
i = 1; | ||
} else { | ||
pthread_t t2; | ||
pthread_create(&t2,NULL,f1,NULL); | ||
} | ||
|
||
|
||
__goblint_check(i == 0); | ||
|
||
|
||
return 0; | ||
} |