main
test-branch
|
Last change
on this file since bd7a43e 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:
452 bytes
|
| Line | |
|---|
| 1 | #include<pthread.h>
|
|---|
| 2 | #include<assert.h>
|
|---|
| 3 |
|
|---|
| 4 | int f(int x){
|
|---|
| 5 |
|
|---|
| 6 | assert(!x);
|
|---|
| 7 | return x!=0;
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | __thread int id=-1;
|
|---|
| 11 |
|
|---|
| 12 | int isRootWork(){
|
|---|
| 13 | assert(id >= 0);
|
|---|
| 14 | return id == 0;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | int isRoot(){
|
|---|
| 18 | isRootWork();
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | void* thread(void *arg){
|
|---|
| 22 | id=(int)arg;
|
|---|
| 23 | isRoot();
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | int main(){
|
|---|
| 27 | pthread_t t0,t1;
|
|---|
| 28 |
|
|---|
| 29 | pthread_create(&t0, 0, thread, (void*)0);
|
|---|
| 30 | pthread_create(&t1, 0, thread, (void*)1);
|
|---|
| 31 | pthread_join(t0, 0);
|
|---|
| 32 | pthread_join(t1, 0);
|
|---|
| 33 | assert(id==-1);
|
|---|
| 34 | return 0;
|
|---|
| 35 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.