1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include "test.h"
- static pthread_spinlock_t lock = NULL;
- static int washere = 0;
- static void * func(void * arg)
- {
- assert(pthread_spin_trylock(&lock) == EBUSY);
- washere = 1;
- return 0;
- }
- int pthread_test_spin2()
- {
- pthread_t t;
- assert(pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE) == 0);
- assert(pthread_spin_lock(&lock) == 0);
- assert(pthread_create(&t, NULL, func, NULL) == 0);
- assert(pthread_join(t, NULL) == 0);
- assert(pthread_spin_unlock(&lock) == 0);
- assert(pthread_spin_destroy(&lock) == 0);
- assert(washere == 1);
- return 0;
- }
|