Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

880 Function Prototypes Appendix A


int semget(key_tkey,intnsems,intflag);
<sys/sem.h> p. 567
flag:IPC_CREAT, IPC_EXCL
Returns: semaphore ID if OK,−1 on error

int sem_getvalue(sem_t *restrictsem,int *restrictvalp);
<semaphore.h> p. 582
Returns: 0 if OK,−1 on error

int sem_init(sem_t *sem,intpshared,unsigned intvalue);
<semaphore.h> p. 582
Returns: 0 if OK,−1 on error

int semop(intsemid,struct sembufsemoparray[], size_tnops);
<sys/sem.h> p. 568
Returns: 0 if OK,−1 on error

sem_t *sem_open(const char *name,intoflag,... /* mode_tmode,
unsigned intvalue*/ );
<semaphore.h> p. 579
flag:IPC_CREAT, IPC_EXCL
Returns: pointer to semaphore if OK,SEM_FAILEDon error

int sem_post(sem_t *sem);
<semaphore.h> p. 582
Returns: 0 if OK,−1 on error

int sem_timedwait(sem_t *restrictsem,
const struct timespec *restricttsptr);
<semaphore.h> p. 581
<time.h>
Returns: 0 if OK,−1 on error

int sem_trywait(sem_t *sem);
<semaphore.h>
Returns: 0 if OK,−1 on error

int sem_unlink(const char *name);
<semaphore.h> p. 580
Returns: 0 if OK,−1 on error

int sem_wait(sem_t *sem);
<semaphore.h> p. 581
Returns: 0 if OK,−1 on error
Free download pdf