89 The semaphore can synchronize threads only in this process. The \fIarg\fR
90 argument is ignored. \fBUSYNC_THREAD\fR does not support multiple mappings to
91 the same logical synch object. If you need to \fBmmap()\fR a synch object to
92 different locations within the same address space, then the synch object should
93 be initialized as a shared object \fBUSYNC_PROCESS\fR for Solaris threads and
94 \fBPTHREAD_PROCESS_PRIVATE\fR for POSIX threads.
95 .RE
96
97 .sp
98 .LP
99 A semaphore must not be simultaneously initialized by multiple threads, nor
100 re-initialized while in use by other threads.
101 .sp
102 .LP
103 Default semaphore initialization (intra-process):
104 .sp
105 .in +2
106 .nf
107 sema_t sp;
108 int count = 1;
109 sema_init(&sp, count, NULL, NULL);
110 .fi
111 .in -2
112
113 .sp
114 .LP
115 or
116 .sp
117 .in +2
118 .nf
119 sema_init(&sp, count, USYNC_THREAD, NULL);
120 .fi
121 .in -2
122
123 .sp
124 .LP
125 Customized semaphore initialization (inter-process):
126 .sp
127 .in +2
128 .nf
129 \fBsema_t sp;
|
89 The semaphore can synchronize threads only in this process. The \fIarg\fR
90 argument is ignored. \fBUSYNC_THREAD\fR does not support multiple mappings to
91 the same logical synch object. If you need to \fBmmap()\fR a synch object to
92 different locations within the same address space, then the synch object should
93 be initialized as a shared object \fBUSYNC_PROCESS\fR for Solaris threads and
94 \fBPTHREAD_PROCESS_PRIVATE\fR for POSIX threads.
95 .RE
96
97 .sp
98 .LP
99 A semaphore must not be simultaneously initialized by multiple threads, nor
100 re-initialized while in use by other threads.
101 .sp
102 .LP
103 Default semaphore initialization (intra-process):
104 .sp
105 .in +2
106 .nf
107 sema_t sp;
108 int count = 1;
109 sema_init(&sp, count, 0, NULL);
110 .fi
111 .in -2
112
113 .sp
114 .LP
115 or
116 .sp
117 .in +2
118 .nf
119 sema_init(&sp, count, USYNC_THREAD, NULL);
120 .fi
121 .in -2
122
123 .sp
124 .LP
125 Customized semaphore initialization (inter-process):
126 .sp
127 .in +2
128 .nf
129 \fBsema_t sp;
|