-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Freiburg nondet_inc_with_ghosts examples
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// PARAM: --enable ana.sv-comp.functions --set ana.activated[+] apron --set ana.relation.privatization mutex-meet --set sem.int.signed_overflow assume_none | ||
#include <pthread.h> | ||
#include <assert.h> | ||
|
||
extern int __VERIFIER_nondet_int(); | ||
extern void __VERIFIER_atomic_begin(); | ||
extern void __VERIFIER_atomic_end(); | ||
|
||
int x = 0; | ||
int g = 0; | ||
|
||
void* inc() | ||
{ | ||
int n = __VERIFIER_nondet_int(); | ||
|
||
while (x < n) { | ||
__VERIFIER_atomic_begin(); | ||
x++; | ||
__VERIFIER_atomic_end(); | ||
|
||
__VERIFIER_atomic_begin(); | ||
assert(x >= g); // TODO | ||
__VERIFIER_atomic_end(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t tid; | ||
pthread_create(&tid, 0, inc, 0); | ||
|
||
int val = __VERIFIER_nondet_int(); | ||
__VERIFIER_atomic_begin(); | ||
g = val; x = val; | ||
__VERIFIER_atomic_end(); | ||
|
||
__VERIFIER_atomic_begin(); // TODO: atomic needed? | ||
assert(x >= val); // TODO | ||
__VERIFIER_atomic_end(); | ||
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,38 @@ | ||
// PARAM: --enable ana.sv-comp.functions --set ana.activated[+] apron --set ana.relation.privatization mutex-meet --set sem.int.signed_overflow assume_none | ||
#include <pthread.h> | ||
#include <assert.h> | ||
|
||
extern int __VERIFIER_nondet_int(); | ||
extern void __VERIFIER_atomic_begin(); | ||
extern void __VERIFIER_atomic_end(); | ||
|
||
int x = 0; | ||
int g = 0; | ||
|
||
void* inc() | ||
{ | ||
__VERIFIER_atomic_begin(); | ||
x++; | ||
__VERIFIER_atomic_end(); | ||
|
||
__VERIFIER_atomic_begin(); | ||
assert(x >= g); // TODO | ||
__VERIFIER_atomic_end(); | ||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t tid; | ||
pthread_create(&tid, 0, inc, 0); | ||
|
||
int val = __VERIFIER_nondet_int(); | ||
__VERIFIER_atomic_begin(); | ||
g = val; x = val; | ||
__VERIFIER_atomic_end(); | ||
|
||
__VERIFIER_atomic_begin(); // TODO: atomic needed? | ||
assert(x >= val); // TODO | ||
__VERIFIER_atomic_end(); | ||
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,34 @@ | ||
// PARAM: --enable ana.sv-comp.functions --set ana.activated[+] apron --set ana.relation.privatization mutex-meet --set sem.int.signed_overflow assume_none | ||
#include <pthread.h> | ||
#include <assert.h> | ||
|
||
extern int __VERIFIER_nondet_int(); | ||
extern void __VERIFIER_atomic_begin(); | ||
extern void __VERIFIER_atomic_end(); | ||
|
||
int x = 0; | ||
int g = 0; | ||
|
||
void* inc() | ||
{ | ||
__VERIFIER_atomic_begin(); | ||
assert(x >= g); | ||
__VERIFIER_atomic_end(); | ||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t tid; | ||
pthread_create(&tid, 0, inc, 0); | ||
|
||
int val = __VERIFIER_nondet_int(); | ||
__VERIFIER_atomic_begin(); | ||
g = val; x = val; | ||
__VERIFIER_atomic_end(); | ||
|
||
__VERIFIER_atomic_begin(); // TODO: atomic needed? | ||
assert(x >= val); // TODO | ||
__VERIFIER_atomic_end(); | ||
return 0; | ||
} |