  563

pthread_cond_wait (mutex, cond):

value = cond->value; /* 1 */
pthread_mutex_unlock (mutex); /* 2 */
pthread_mutex_lock (cond->mutex); /* 10 */
if (value == cond->value) { /* 11 */

me->next_cond = cond->waiter;

cond->waiter = me;

pthread_mutex_unlock (cond->mutex) ;

unable_to_run (me) ;

} else

pthread_mutex_unlock (cond->mutex); /* 12 */
pthread_mutex_iock (mutex); /* 13 * /
pthread_cond_signal (cond):

pthread_mutex_lock (cond->mutex); /* 3 */

cond->value++; /* 4 */

if (cond->waiter) { /* 5 */

sleeper = cond->waiter; /* 6 */

cond->waiter = sleeper->next_cond; /* 7 */

able_to_run (sleeper); /* 8 */
}
pthread_mutex_unlock (cond->mutex); /* 9 */

,       pthread_cond_signal () 
       pthread_cond_wait () 
pthread_cond_timedwait ().    " ". -
   ,      -
 ,   , ""  , ;

,  ,    pthread_cond_wait (),
    .

         ,  
   ,    , -
,   ,    ,   
.         -
         
 .

  " "    :

  ,      
     .    -
 ""    ""  , -
       ,     -
  -   .    
 .    IEEE Std 1003.1-2001    -
   " ".

 

.