123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #include "test.h"
- enum
- {
- NUMTHREADS = 20
- };
- static void *
- func(void * arg)
- {
- int i = (int) arg;
- pte_osThreadSleep(i * 10);
- pthread_exit(arg);
-
- exit(1);
-
- return NULL;
- }
- int pthread_test_detach1()
- {
- pthread_t id[NUMTHREADS];
- int i;
-
- for (i = 0; i < NUMTHREADS; i++)
- {
- assert(pthread_create(&id[i], NULL, func, (void *) i) == 0);
- }
-
- pte_osThreadSleep(NUMTHREADS/2 * 10 + 50);
- for (i = 0; i < NUMTHREADS; i++)
- {
- assert(pthread_detach(id[i]) == 0);
- }
- pte_osThreadSleep(NUMTHREADS * 10 + 1000);
-
- for (i = 0; i < NUMTHREADS; i++)
- {
- assert(pthread_kill(id[i], 0) == ESRCH);
- }
-
- return 0;
- }
|