条件变量本质-Problem statement-while not( P ) do skip

条件变量相当于订阅-发布机制;

或者相当于同步的通知机制;

 

订阅和发布具有先后顺序;所以需要互斥量来维护顺序。

顺序不对,存在信号丢失问题。

 

Problem statement[edit]

For many applications, mutual exclusion is not enough. Threads attempting an operation may need to wait until some condition P holds true. A busy waiting loop

   while not( P ) do skip

will not work, as mutual exclusion will prevent any other thread from entering the monitor to make the condition true.

 

https://en.wikipedia.org/wiki/Monitor_(synchronization)#Condition_variables

posted @ 2018-01-25 22:17  zzfx  阅读(198)  评论(0编辑  收藏  举报