4.11.      179

//  4.10.    
//               "-"

pthread_mutex_t Mutex = PTHREAD_MUTEX_INITIALIZER

pthread_t Thread[2]

Queue

//  .
{

pthread_create(&(Thread[1]...producer...) ;

pthread_create(&(Thread[2]...consumer...) ;

//. . .
}

void *producer(void *X) // -""
{



 

pthread_routex_lock(&Mutex)

   
pthread_mutex_unlock(&Mutex)

 
//. . .
 
}

void "consumer (void *X) // -"
{



   
 while(   )
pthread_mutex_lock(&Mutex)

   
pthread_mutex_unlock(&Mutex)

 
 
 
}

  4.9     : ""  "".
-""  ,      -
      ,    
   .   "" 
    -""  ,     
  . -""      , 
    . -""   ,  
    ,    .    -
"      ,    .  -
           -
   .      .  -
 4.6 -""     .   
    .  -""  
:  ,   .   ""  -
  ,  -"",  
   "",    ,   -
   , ""  .