1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "test.h"
- static int lockCount = 0;
- static pthread_mutex_t mutex;
- static void * locker(void * arg)
- {
- assert(pthread_mutex_lock(&mutex) == 0);
- lockCount++;
- assert(pthread_mutex_trylock(&mutex) == EBUSY);
- lockCount++;
- assert(pthread_mutex_unlock(&mutex) == 0);
- assert(pthread_mutex_unlock(&mutex) == EPERM);
- return 0;
- }
- int
- pthread_test_mutex7()
- {
- pthread_t t;
- lockCount = 0;
- assert(pthread_mutex_init(&mutex, NULL) == 0);
- assert(pthread_create(&t, NULL, locker, NULL) == 0);
- pte_osThreadSleep(1000);
- assert(lockCount == 2);
- assert(pthread_join(t,NULL) == 0);
- assert(pthread_mutex_destroy(&mutex) == 0);
-
- return 0;
- }
|