main
test-branch
|
Last change
on this file since 1aaefd4 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.3 KB
|
| Line | |
|---|
| 1 | #include <pthread.h>
|
|---|
| 2 |
|
|---|
| 3 | #define assume(e) __VERIFIER_assume(e)
|
|---|
| 4 | #define assert(e) { if(!(e)) { ERROR: goto ERROR; (void)0; } }
|
|---|
| 5 |
|
|---|
| 6 | int mThread=0;
|
|---|
| 7 | int start_main=0;
|
|---|
| 8 | int mStartLock=0;
|
|---|
| 9 | int __COUNT__ =0;
|
|---|
| 10 |
|
|---|
| 11 | void __VERIFIER_atomic_acquire()
|
|---|
| 12 | {
|
|---|
| 13 | assume(mStartLock==0);
|
|---|
| 14 | mStartLock = 1;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | void __VERIFIER_atomic_release()
|
|---|
| 18 | {
|
|---|
| 19 | assume(mStartLock==1);
|
|---|
| 20 | mStartLock = 0;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | void __VERIFIER_atomic_thr1(int PR_CreateThread__RES)
|
|---|
| 24 | {
|
|---|
| 25 | if( __COUNT__ == 0 ) { // atomic check(0);
|
|---|
| 26 | mThread = PR_CreateThread__RES;
|
|---|
| 27 | __COUNT__ = __COUNT__ + 1;
|
|---|
| 28 | } else { assert(0); }
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | void* thr1(void* arg) { //nsThread::Init (mozilla/xpcom/threads/nsThread.cpp 1.31)
|
|---|
| 32 |
|
|---|
| 33 | int PR_CreateThread__RES = 1;
|
|---|
| 34 | __VERIFIER_atomic_acquire();
|
|---|
| 35 | start_main=1;
|
|---|
| 36 | __VERIFIER_atomic_thr1(PR_CreateThread__RES);
|
|---|
| 37 | __VERIFIER_atomic_release();
|
|---|
| 38 |
|
|---|
| 39 | return 0;
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | void __VERIFIER_atomic_thr2(int self)
|
|---|
| 43 | {
|
|---|
| 44 | if( __COUNT__ == 1 ) { // atomic check(1);
|
|---|
| 45 | //int rv = self; // self->RegisterThreadSelf();
|
|---|
| 46 | __COUNT__ = __COUNT__ + 1;
|
|---|
| 47 | } else { assert(0); }
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | void* thr2(void* arg) { //nsThread::Main (mozilla/xpcom/threads/nsThread.cpp 1.31)
|
|---|
| 51 |
|
|---|
| 52 | int self = mThread;
|
|---|
| 53 | while (start_main==0);
|
|---|
| 54 | __VERIFIER_atomic_acquire();
|
|---|
| 55 | __VERIFIER_atomic_release();
|
|---|
| 56 | __VERIFIER_atomic_thr2(self);
|
|---|
| 57 |
|
|---|
| 58 | return 0;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | int main()
|
|---|
| 62 | {
|
|---|
| 63 | pthread_t t;
|
|---|
| 64 |
|
|---|
| 65 | pthread_create(&t, 0, thr1, 0);
|
|---|
| 66 | thr2(0);
|
|---|
| 67 |
|
|---|
| 68 | return 0;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.