????4???????????????

????1??????????????????????????

????2??????????????????????

????3???????????????????

????4??????ж????? ?????????ABC???????????????????ABC??

????5?????????????????????????????

????????????????

????1???????????

???????????????????????????о???????????????

????a????????

?????????????PTHREAD_COND_INITIALIZER???????磺pthread_cond_t  cond = PTHREAD_COND_INITIALIZER

????b????????

????int pthread_cond_init(pthread_cond_t *cond??pthread_condattr_t *cond_attr)

??????? cond_attr ????????????????????? cond???? cond_attr? NULL???????????????LinuxThreads???????????????????????? cond_attr?????????????

????c?????

????int pthread_cond_destroy(pthread_cond_t *cond)

?????????????????????????pthread_cond_destroy()??????????????????????????????????????????????????????????EBUSY?????Linux??????????????з?????????????????????????????????е??????

????2??????????

????2.1 ???

????int pthread_cond_wait(pthread_cond_t *cond?? pthread_mutex_t *mutex)

?????????????POSIX???????????????????????????????????????????-wait-??????-????-?????

????2.2 ??????????

????int pthread_cond_timedwait(pthread_cond_t *cond?? pthread_mutex_t *mutex?? conststruct timespec *abstime)

????pthread_cond_timedwait?? pthread_cond_wait?????????????????????????????????????????????????????? abstime?????????? condδ???????????? mutex???????????????????? ETIMEDOUT??abstime????????????????????? time?? gettimeofday?????abstime = 0??? 1970 ?? 1?? 1 ?? 00:00:00 GMT??

????2.3 ????

????int pthread_cond_signal(pthread_cond_t *cond);
????int pthread_cond_broadcast(pthread_cond_t *cond);

???????????????????????pthread_cond_signal()??????????????????????????????????????????????????????????????????????????????????????pthread_cond_broadcast()???????е????????Щ???????????ξ???????????????

??????????????????????????????????????????????????????????????????п?????????????????pthread_cond_wait()??????????????????????????????

????????????????????????

??????????????????????????????????????????????????????У??????????????????????????????????????????????????????????磬??????????????????????????????????????????????????????????????????????????????ζ????鹲???????????????????????????????????????????????????????Ч????????????????μ????????????????????????????3s?????????????????????????????

??????????????????????????????????????????????????????????????????????????????????????????????á????????????????????????????????????????????????????????????????????????????????仯???????????????????????????????????????????????????????????????????????????????????????Щ???????????????????????2??????????????