228 .sp
229 .LP
230 Initializing mutexes can also be accomplished by allocating in zeroed memory
231 (default), in which case a \fItype\fR of \fBUSYNC_THREAD\fR is assumed. In
232 general, the following rules apply to mutex initialization:
233 .RS +4
234 .TP
235 .ie t \(bu
236 .el o
237 The same mutex must not be simultaneously initialized by multiple threads.
238 .RE
239 .RS +4
240 .TP
241 .ie t \(bu
242 .el o
243 A mutex lock must not be reinitialized while in use by other threads.
244 .RE
245 .sp
246 .LP
247 These rules do not apply to \fBLOCK_ROBUST\fR mutexes. See the description for
248 \fBLOCK_ROBUST\fRabove. If default mutex attributes are used, the macro
249 \fBDEFAULTMUTEX\fR can be used to initialize mutexes that are statically
250 allocated.
251 .sp
252 .LP
253 Default mutex initialization (intra-process):
254 .sp
255 .in +2
256 .nf
257 mutex_t mp;
258 mutex_init(&mp, USYNC_THREAD, NULL);
259 .fi
260 .in -2
261
262 .sp
263 .LP
264 or
265 .sp
266 .in +2
267 .nf
268 mutex_t mp = DEFAULTMUTEX;
|
228 .sp
229 .LP
230 Initializing mutexes can also be accomplished by allocating in zeroed memory
231 (default), in which case a \fItype\fR of \fBUSYNC_THREAD\fR is assumed. In
232 general, the following rules apply to mutex initialization:
233 .RS +4
234 .TP
235 .ie t \(bu
236 .el o
237 The same mutex must not be simultaneously initialized by multiple threads.
238 .RE
239 .RS +4
240 .TP
241 .ie t \(bu
242 .el o
243 A mutex lock must not be reinitialized while in use by other threads.
244 .RE
245 .sp
246 .LP
247 These rules do not apply to \fBLOCK_ROBUST\fR mutexes. See the description for
248 \fBLOCK_ROBUST\fR above. If default mutex attributes are used, the macro
249 \fBDEFAULTMUTEX\fR can be used to initialize mutexes that are statically
250 allocated.
251 .sp
252 .LP
253 Default mutex initialization (intra-process):
254 .sp
255 .in +2
256 .nf
257 mutex_t mp;
258 mutex_init(&mp, USYNC_THREAD, NULL);
259 .fi
260 .in -2
261
262 .sp
263 .LP
264 or
265 .sp
266 .in +2
267 .nf
268 mutex_t mp = DEFAULTMUTEX;
|