1.23
2.0
main
test-branch
|
Last change
on this file since d87ec9c was 16d81051, checked in by John Edenhofner <johneden@…>, 12 years ago |
|
Added more tests to PthreadTests, modified transformer to only add pthread_exit(NULL) to void pointer methods that will be called as a thread. Transforms each main to have a return(0) call at its end so that the thread pool is freed each time (frees upon return)
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@1236 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
503 bytes
|
| Line | |
|---|
| 1 | #include <stdlib.h>
|
|---|
| 2 | #include <pthread.h>
|
|---|
| 3 | #include <string.h>
|
|---|
| 4 |
|
|---|
| 5 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: goto ERROR; }; return; }
|
|---|
| 6 |
|
|---|
| 7 | char *v;
|
|---|
| 8 |
|
|---|
| 9 | void *thread1(void * arg)
|
|---|
| 10 | {
|
|---|
| 11 | v = malloc(sizeof(char) * 8);
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | void *thread2(void *arg)
|
|---|
| 15 | {
|
|---|
| 16 | if (v) strcpy(v, "Bigshot");
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 | int main()
|
|---|
| 21 | {
|
|---|
| 22 | pthread_t t1, t2;
|
|---|
| 23 |
|
|---|
| 24 | pthread_create(&t1, 0, thread1, 0);
|
|---|
| 25 | pthread_create(&t2, 0, thread2, 0);
|
|---|
| 26 | pthread_join(t1, 0);
|
|---|
| 27 | pthread_join(t2, 0);
|
|---|
| 28 |
|
|---|
| 29 | __VERIFIER_assert(!v || v[0] == 'B');
|
|---|
| 30 |
|
|---|
| 31 | return 0;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.