16 static pthread_attr_t thr_attr;
25 if (nthreads >= max_threads) {
27 "no more than %ui threads can be created", max_threads);
31 err = pthread_create(tid, &thr_attr, func, arg);
54 err = pthread_attr_init(&thr_attr);
58 "pthread_attr_init() failed");
62 err = pthread_attr_setstacksize(&thr_attr, size);
66 "pthread_attr_setstacksize() failed");
89 err = pthread_mutex_init(&m->mutex, NULL);
93 "pthread_mutex_init() failed");
106 err = pthread_mutex_destroy(&m->mutex);
110 "pthread_mutex_destroy(%p) failed", m);
128 err = pthread_mutex_lock(&m->mutex);
132 "pthread_mutex_lock(%p) failed", m);
153 err = pthread_mutex_trylock(&m->mutex);
161 "pthread_mutex_trylock(%p) failed", m);
182 err = pthread_mutex_unlock(&m->mutex);
186 "pthread_mutex_unlock(%p) failed", m);
209 err = pthread_cond_init(&cv->cond, NULL);
213 "pthread_cond_init() failed");
226 err = pthread_cond_destroy(&cv->cond);
230 "pthread_cond_destroy(%p) failed", cv);
244 err = pthread_cond_wait(&cv->cond, &m->mutex);
248 "pthread_cond_wait(%p) failed", cv);
267 err = pthread_cond_signal(&cv->cond);
271 "pthread_cond_signal(%p) failed", cv);