|
|
1.1 root 1:
2:
3: semget() COHERENT System Call semget()
4:
5:
6:
7:
8: Get a set of semaphores
9:
10: #include <sys/sem.h>
11: sseemmggeett(_k_e_y, _n_s_e_m_s, _s_e_m_f_l_g)
12: kkeeyy_tt _k_e_y; iinntt _n_s_e_m_s, _s_e_m_f_l_g;
13:
14: semget returns the semaphore identifier associated with key. It
15: creates a semaphore identifier and associated data structure and
16: set that contains nsems semaphores for key should one of the
17: following be true:
18:
19: * key equals IPC_PRIVATE.
20:
21: * key does not have a semaphore identifier associated with it,
22: and (_s_e_m_f_l_g & IIPPCC_CCRREEAATT) is true.
23:
24: When semget creates a data structure for a new semaphore iden-
25: tifier, it initializes the structure as follows:
26:
27: * It sets the fields sem_perm.cuid, sem_perm.uid, sem_perm.cgid,
28: and sem_perm.gid equal to the effective user identifier, the
29: calling process's identifier, and the effective group iden-
30: tifier, respectively.
31:
32: * It sets the low-order nine bits of sem_perm.mode equal to the
33: low-order nine bits of semflg. These nine bits define access
34: permissions: the top three bits specify the owner's access
35: permissions (read, write, execute), the middle three bits the
36: owning group's access permissions, and the low three bits ac-
37: cess permissions for others.
38:
39: * sem_nsems is set equal to the value of nsems.
40:
41: * sem_otime is set to zero and sem_ctime to the current time.
42:
43: semget fails if any of the following are true:
44:
45: * nsems is either less than or equal to zero, or greater than
46: the system imposed limit. It sets errno to EINVAL.
47:
48: * A semaphore identifier exists for key but operation permission
49: as specified by the low-order nine bits of semflg would not be
50: granted (EEAACCCCEESS).
51:
52: * A semaphore identifier exists for key but the number of
53: semaphores in the set associated with it is less than nsems
54: and nsems is not equal to zero (EEIINNVVAALL).
55:
56: * A semaphore identifier does not exist for key and (_s_e_m_f_l_g &
57: IIPPCC_CCRREEAATT) is false (EENNOOEENNTT).
58:
59: * The number of semaphore identifiers allowed system-wide would
60: be exceeded (EENNOOSSPPCC).
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
67:
68:
69: semget() COHERENT System Call semget()
70:
71:
72:
73: * The number of semaphores allowed system-wide would be exceeded
74: (EENNOOSSPPCC).
75:
76: * A semaphore identifier exists for key but ( (_s_e_m_f_l_g &
77: IIPPCC_CCRREEAATT) && (_s_e_m_f_l_g & IIPPCC_EEXXCCLL) ) is true (EEEEXXIISSTT).
78:
79: ***** Return Value *****
80:
81: Upon successful completion, semget returns a non-negative in-
82: teger, namely a semaphore identifier. Otherwise, it returns -1
83: and sets eerrrrnnoo to an appropriate value.
84:
85: ***** Files *****
86:
87: /usr/include/sys/ipc.h
88: /usr/include/sys/sem.h
89: /dev/sem
90: /drv/sem
91:
92: ***** See Also *****
93:
94: COHERENT system calls, sem, semctl(), semop()
95:
96: ***** Notes *****
97:
98: To improve portability, the COHERENT system implements the
99: semaphore functions as a device driver rather than as an actual
100: system call.
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130: COHERENT Lexicon Page 2
131:
132:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.