This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
semlib.h
57 lines (37 loc) · 1.42 KB
/
semlib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* SEMLIB.H
*
* Interface definition of a simple semaphore library for using
* in inherited programs (parent-child relationship).
*/
#ifndef _SEMLIB_H_
#define _SEMLIB_H_
/* Obtains a new array of semaphores from the system. The number
* of semaphores in the array is <nsem>, and they all have the initial
* value of <init_val>. The function returns the semaphore id (semid)
* of the set, or -1 on error. The semaphores in the set range from 0
* to nsem-1.
*/
extern int sem_get(int nsem, int init_val);
/* Releases a semaphore set that is no longer in use. <sem_id> identifies
* the semaphore set.
*/
extern void sem_close(int sem_id);
/* Performs a wait on a certain semaphore in a semaphore set. The semaphore
* set is <sem_id>, and <sem_num> represents the particular semaphore in
* question.
*/
extern void sem_wait(int sem_id, int sem_num);
/* Performs a signal on a certain semaphore in a semaphore set. The semaphore
* set is <sem_id>, and <sem_num> represents the particular semaphore in
* question.
*/
extern void sem_signal(int sem_id, int sem_num);
/*
* Directly sets the value of a semaphore in a semaphore set to a
* certain value. The semaphore set is identified by <sem_id>, and the
* semaphore is <sem_num>. <value> represents the new value of the semaphore.
* This routine should only be used for initializing semaphores.
*/
extern void sem_setvalue(int sem_id, int sem_num, int value);
#endif