11.2.   -  ... 391

  .        -
 ,      , -
     .  ,  -
   ,    -
   .

 ,     "" , 
   POSIX-.       -
 Pthread,       . 
   ,     
 .         -
 ,    mutex.

  semaphore    11.10.

//  11.10.   semaphore

class semaphore : public synchronization_variable(
protected:

sem_t *Semaphore;

public:

//. . .

int lock(void) ;

int unlock(void);

int trylock(void);

//. . .
};



<semaphore.h>

int sem_init(sem_t *, int, unsigned int);

int sem_destroy(sem_t *);

sem_t *sem_open(const char *, int, ...) ;

int sem_close(sem_t *);

int sem_unlink(const char *);

int sem_wait(sem_t *);

int sem_trywait(sem_t *);

int sem_post(sem_t *);

int sem_gefcvalue(sem_t *, int *);

   ,   semaphore    , 
   mutex.    ?    mutex
 semaphore ,   lock (), unlock (), trylock ()  
       POSIX.

//  11.11.   lock(), unlock() 
//                trylock()   semaphore

int semaphore::lock(void)

{

//. . .
return(sem_wait(Semaphore)) ;

}