1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "test.h"
- static pthread_mutex_t mutex1 = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER;
- static int washere = 0;
- static void * func(void * arg)
- {
- assert(pthread_mutex_trylock(&mutex1) == EBUSY);
- washere = 1;
- return 0;
- }
- int
- pthread_test_mutex3e()
- {
- pthread_t t;
- mutex1 = PTHREAD_ERRORCHECK_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(pthread_mutex_destroy(&mutex1) == 0);
- assert(washere == 1);
- return 0;
- }
|