diff options
author | rpj <rpj> | 1999-03-08 21:02:20 +0000 |
---|---|---|
committer | rpj <rpj> | 1999-03-08 21:02:20 +0000 |
commit | 52f7c3f5ef6d9b70ec385fb390bf27962e68ee3d (patch) | |
tree | 030c60c1dcddf64c66956490a8b6333e0036a9bd /tests/Template.c | |
parent | 1e9697f3e8f5da2f710a98d9ae8ce3105e61a4a6 (diff) |
Resolve merge conflicts; minor comment changes.
Diffstat (limited to 'tests/Template.c')
-rw-r--r-- | tests/Template.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/tests/Template.c b/tests/Template.c index 0663a85..c98bbac 100644 --- a/tests/Template.c +++ b/tests/Template.c @@ -44,18 +44,18 @@ /* * Create NUMTHREADS threads in addition to the Main thread. */ -static enum { +enum { NUMTHREADS = 2 }; typedef struct bag_t_ bag_t; struct bag_t_ { int threadnum; - int washere; - /* Add more pre-thread state variables here */ + int started; + /* Add more per-thread state variables here */ }; -static bag_t threadbag[NUMTHREADS]; +static bag_t threadbag[NUMTHREADS + 1]; void * mythread(void * arg) @@ -63,8 +63,8 @@ mythread(void * arg) bag_t * bag = (bag_t *) arg; assert(bag == &threadbag[bag->threadnum]); - assert(bag->washere == 0); - bag->washere = 1; + assert(bag->started == 0); + bag->started = 1; /* ... */ @@ -80,13 +80,18 @@ main() assert((t[0] = pthread_self()) != NULL); for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].washere = 0; + { + threadbag[i].started = 0; threadbag[i].threadnum = i; assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); } /* + * Code to control or munipulate child threads should probably go here. + */ + + + /* * Give threads time to run. */ Sleep(NUMTHREADS * 1000); @@ -96,24 +101,25 @@ main() */ for (i = 1; i <= NUMTHREADS; i++) { - if (threadbag[i].washere != 1) + failed = !threadbag[i].started; + + if (failed) { - failed = 1; - fprintf(stderr, "Thread %d: washere %d\n", i, threadbag[i].washere); + fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); } } - assert(failed == 0); + assert(!failed); /* - * Check any results here. Only print ouput and set "failed" on failure. + * Check any results here. Set "failed" and only print ouput on failure. */ for (i = 1; i <= NUMTHREADS; i++) { /* ... */ } - assert(failed == 0); + assert(!failed); /* * Success. |