View | Details | Raw Unified | Return to bug 134074
Collapse All | Expand All

(-)share/man/man9/locking.9 (-26 / +26 lines)
Lines 220-247 Link Here
220
When a thread waits on a condition, the mutex
220
When a thread waits on a condition, the mutex
221
is atomically released before the thread is blocked, then reacquired
221
is atomically released before the thread is blocked, then reacquired
222
before the function call returns.
222
before the function call returns.
223
.Ss Giant
224
Giant is a special instance of a sleep lock.
225
It has several special characteristics.
226
.Bl -enum
227
.It
228
It is recursive.
229
.It
230
Drivers can request that Giant be locked around them, but this is
231
going away.
232
.It
233
You can sleep while it has recursed, but other recursive locks cannot.
234
.It
235
Giant must be locked first before other locks.
236
.It
237
There are places in the kernel that drop Giant and pick it back up
238
again.
239
Sleep locks will do this before sleeping.
240
Parts of the Network or VM code may do this as well, depending on the
241
setting of a sysctl.
242
This means that you cannot count on Giant keeping other code from
243
running if your code sleeps, even if you want it to.
244
.El
245
.Ss Sleep/wakeup
223
.Ss Sleep/wakeup
246
The functions
224
The functions
247
.Fn tsleep ,
225
.Fn tsleep ,
Lines 298-303 Link Here
298
.Va Giant
276
.Va Giant
299
mutex before the function returns.
277
mutex before the function returns.
300
.Pp
278
.Pp
279
.Ss Giant
280
Giant is a special instance of a sleep lock.
281
It has several special characteristics.
282
.Bl -enum
283
.It
284
It is recursive.
285
.It
286
Drivers can request that Giant be locked around them, but this is
287
going away.
288
.It
289
You can sleep while it has recursed, but other recursive locks cannot.
290
.It
291
Giant must be locked first before other locks.
292
.It
293
There are places in the kernel that drop Giant and pick it back up
294
again.
295
Sleep locks will do this before sleeping.
296
Parts of the Network or VM code may do this as well, depending on the
297
setting of a sysctl.
298
This means that you cannot count on Giant keeping other code from
299
running if your code sleeps, even if you want it to.
300
.El
301
.Ss lockmanager locks
301
.Ss lockmanager locks
302
Largely deprecated.
302
Largely deprecated.
303
See the
303
See the
Lines 325-335 Link Here
325
Lock order is important.
325
Lock order is important.
326
.Pp
326
.Pp
327
.Em *2
327
.Em *2
328
readers can recurse though writers can not.
328
Readers can recurse though writers can not.
329
Lock order is important.
329
Lock order is important.
330
.Pp
330
.Pp
331
.Em *3
331
.Em *3
332
There are calls atomically release this primitive when going to sleep
332
There are calls to atomically release this primitive when going to sleep
333
and reacquire it on wakeup (e.g.
333
and reacquire it on wakeup (e.g.
334
.Fn mtx_sleep ,
334
.Fn mtx_sleep ,
335
.Fn rw_sleep
335
.Fn rw_sleep
Lines 340-346 Link Here
340
.Em *4
340
.Em *4
341
Though one can sleep holding an sx lock, one can also use
341
Though one can sleep holding an sx lock, one can also use
342
.Fn sx_sleep
342
.Fn sx_sleep
343
which atomically release this primitive when going to sleep and
343
which will atomically release this primitive when going to sleep and
344
reacquire it on wakeup.
344
reacquire it on wakeup.
345
.Ss Context mode table.
345
.Ss Context mode table.
346
The next table shows what can be used in different contexts.
346
The next table shows what can be used in different contexts.
Lines 363-369 Link Here
363
.Xr sleep 9 ,
363
.Xr sleep 9 ,
364
.Xr sx 9 ,
364
.Xr sx 9 ,
365
.Xr LOCK_PROFILING 9 ,
365
.Xr LOCK_PROFILING 9 ,
366
.Xr WITNESS 9
366
.Xr witness 4
367
.Sh HISTORY
367
.Sh HISTORY
368
These
368
These
369
functions appeared in
369
functions appeared in

Return to bug 134074