12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "test.h"
- static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
- static int washere = 0;
- static void * func(void * arg)
- {
- assert(pthread_mutex_trylock(&mutex1) == EBUSY);
- washere = 1;
- return 0;
- }
- int
- pthread_test_mutex3()
- {
- pthread_t t;
- mutex1 = PTHREAD_MUTEX_INITIALIZER;
- assert(pthread_mutex_lock(&mutex1) == 0);
- assert(pthread_create(&t, NULL, func, NULL) == 0);
- assert(pthread_join(t, NULL) == 0);
- assert(pthread_mutex_unlock(&mutex1) == 0);
- assert(washere == 1);
- assert(pthread_mutex_destroy(&mutex1) == 0);
- return 0;
- }
|