linux线程 | 条件变量、信号量
2023-05-21
42 浏览
#include
/*超时等待*/
int pthread_cond_timedwait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstime);
/*条件变量阻塞等待*/
int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex);
#include
int pthread_cond_destroy(pthread_cond_t *cond);
int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr);
pthread_cond_t cond = pthread_cond_initializer;
#include
/*唤醒阻塞在条件变量cond上的全部线程*/
int pthread_cond_broadcast(pthread_cond_t *cond);
/*唤醒至少一个阻塞在条件上的线程*/
int pthread_cond_signal(pthread_cond_t *cond);
请后发表内容