?? ??? "Unix/Linux ????? ?? ???"?? ??? ????. ?? ??? ? ?? ???? ???? ?? ? ??? ?? ?? ???? ?? ???? ? ?? ???? ????. ??? ?? ???????.
??? ???? ??? ?? ??? ??, ?? ?? ? ?? ??? ????? ??? ?????.
?? ?? ?:
?? ????? pthread_cond_wait
時會釋放互斥鎖,然后掛起主線程,并等待條件變量的發(fā)生變化,當其他線程調(diào)用pthread_cond_signal
時,如果互斥鎖是被鎖住的,那么主線程中的pthread_cond_wait
? ??? ? ???? ?? ??? ??? ????? ???? ?? ???? ?????
1? ??? ???? pthread_cond_wait
收到了pthread_cond_signal
發(fā)來的信號,但是未鎖定互斥鎖之前,又被其他線程搶了先,鎖住了互斥鎖,那不是pthread_cond_wait
??? ??? ??? ??? ??? ???? ????
????? ? ????? ?? ??? ???? ?? ? ??? ??? ????.
?? ?????.
????? ???? ??? ??? ? ??? ??? ?? ??? ?? ??? ?????.
pthread_cond_signal
??? ??
? ??? ??? ?? ??? ?? ????. ?? ??? ??? ???? ??? ???? ??? ?? ?? ?? ???? ?? ??? ???? ????.
?? ??? ??? ?? ???? ?? ???? ?? ??? ?????.