main
test-branch
|
Last change
on this file since bb03188 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | #include <pthread.h>
|
|---|
| 2 |
|
|---|
| 3 | #define assert(e) { if(!(e)) { ERROR: goto ERROR; (void)0; } }
|
|---|
| 4 |
|
|---|
| 5 | int usecount;
|
|---|
| 6 | int locked;
|
|---|
| 7 | int flag1 = 0;
|
|---|
| 8 | int flag2 = 0;
|
|---|
| 9 | int release_thr1 = 0;
|
|---|
| 10 |
|
|---|
| 11 | void* thr2 (void* arg) //dummy_open
|
|---|
| 12 | {
|
|---|
| 13 | while(!release_thr1);
|
|---|
| 14 |
|
|---|
| 15 | usecount = usecount + 1;
|
|---|
| 16 |
|
|---|
| 17 | if (locked)
|
|---|
| 18 | return 0;
|
|---|
| 19 | locked = 1;
|
|---|
| 20 | flag1 = 1;
|
|---|
| 21 | return 0;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | inline void dummy_release ()
|
|---|
| 25 | {
|
|---|
| 26 | usecount = usecount - 1;
|
|---|
| 27 | locked = 0;
|
|---|
| 28 | return;
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | inline void unregister_chrdev ()
|
|---|
| 32 | {
|
|---|
| 33 | if (usecount != 0)
|
|---|
| 34 | {
|
|---|
| 35 | // this should fail
|
|---|
| 36 | assert (0);
|
|---|
| 37 | }
|
|---|
| 38 | else
|
|---|
| 39 | return;
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | void* thr1 (void* arg)
|
|---|
| 43 | {
|
|---|
| 44 | void* rval;
|
|---|
| 45 | int count;
|
|---|
| 46 |
|
|---|
| 47 | usecount = 0;
|
|---|
| 48 | locked = 0;
|
|---|
| 49 |
|
|---|
| 50 | release_thr1 = 1;
|
|---|
| 51 | while(1)
|
|---|
| 52 | {
|
|---|
| 53 | if(flag1)
|
|---|
| 54 | break;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | do
|
|---|
| 58 | {
|
|---|
| 59 | rval = (void*)__VERIFIER_nondet_int();
|
|---|
| 60 | if (rval == 0)
|
|---|
| 61 | {
|
|---|
| 62 | count = 1;
|
|---|
| 63 | dummy_release ();
|
|---|
| 64 | }
|
|---|
| 65 | else
|
|---|
| 66 | count = 0;
|
|---|
| 67 | }
|
|---|
| 68 | while (count != 0);
|
|---|
| 69 |
|
|---|
| 70 | dummy_release ();
|
|---|
| 71 |
|
|---|
| 72 | unregister_chrdev ();
|
|---|
| 73 |
|
|---|
| 74 | return 0;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | int main(){
|
|---|
| 78 | pthread_t t;
|
|---|
| 79 |
|
|---|
| 80 | pthread_create(&t, 0, thr1, 0);
|
|---|
| 81 | while(1) { pthread_create(&t, 0, thr2, 0); }
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.