diff --git a/en_US.ISO8859-1/books/arch-handbook/locking/chapter.sgml b/en_US.ISO8859-1/books/arch-handbook/locking/chapter.sgml index e604ef443b..ed32ed61b5 100644 --- a/en_US.ISO8859-1/books/arch-handbook/locking/chapter.sgml +++ b/en_US.ISO8859-1/books/arch-handbook/locking/chapter.sgml @@ -1,333 +1,313 @@ Locking Notes This chapter is maintained by the FreeBSD SMP Next Generation Project. Please direct any comments or suggestions to its &a.smp;. This document outlines the locking used in the FreeBSD kernel to permit effective multi-processing within the kernel. Locking can be achieved via several means. Data structures can be protected by mutexes or &man.lockmgr.9; locks. A few variables are protected simply by always using atomic operations to access them. Mutexes A mutex is simply a lock used to guarantee mutual exclusion. Specifically, a mutex may only be owned by one entity at a time. If another entity wishes to obtain a mutex that is already owned, it must wait until the mutex is released. In the FreeBSD kernel, mutexes are owned by processes. Mutexes may be recursively acquired, but they are intended to be held for a short period of time. Specifically, one may not sleep while holding a mutex. If you need to hold a lock across a sleep, use a &man.lockmgr.9; lock. Each mutex has several properties of interest: Variable Name The name of the struct mtx variable in the kernel source. Logical Name The name of the mutex assigned to it by mtx_init. This name is displayed in KTR trace messages and witness errors and warnings and is used to distinguish mutexes in the witness code. Type The type of the mutex in terms of the MTX_* flags. The meaning for each flag is related to its meaning as documented in &man.mutex.9;. MTX_DEF A sleep mutex MTX_SPIN A spin mutex - MTX_COLD + MTX_RECURSE - This mutex is initialized very early. Thus, it - must be declared via - MUTEX_DECLARE, and the - MTX_COLD flag must be passed to - mtx_init. - - - - - MTX_TOPHALF - - This spin mutex does not disable - interrupts. - - - - - MTX_NORECURSE - - This mutex is not allowed to recurse. + This mutex is allowed to recurse. Protectees A list of data structures or data structure members that this entry protects. For data structure members, the name will be in the form of Dependent Functions Functions that can only be called if this mutex is held. Mutex List Variable Name Logical Name Type Protectees Dependent Functions sched_lock sched lock MTX_SPIN | - MTX_COLD + MTX_RECURSE _gmonparam, cnt.v_swtch, cp_time, curpriority, P_PROFIL XXX, - P_INMEM, - P_SINTR, - P_TIMEOUT, - P_SWAPINREQ XXX, - P_INMEN XXX), - p_prof/, - p_ru/, + statclock), + pscnt, slpque, itqueuebits, itqueues, rtqueuebits, rtqueues, queuebits, queues, idqueuebits, idqueues, switchtime, + switchticks setrunqueue, remrunqueue, mi_switch, chooseproc, schedclock, resetpriority, updatepri, maybe_resched, cpu_switch, - cpu_throw + cpu_throw, + need_resched, + resched_wanted, + clear_resched, + aston, + astoff, + astpending, + calcru, + proc_compare vm86pcb_lock vm86pcb lock - MTX_DEF | - MTX_COLD + MTX_DEF vm86pcb vm86_bioscall Giant Giant MTX_DEF | - MTX_COLD + MTX_RECURSE nearly everything lots callout_lock callout lock - MTX_SPIN + MTX_SPIN | + MTX_RECURSE callfree, callwheel, nextsoftcheck, softticks, ticks
- - Lock Manager Locks + + Shared Exclusive Locks - Locks that are provided via the &man.lockmgr.9; interface - are lock manager locks. These locks are reader-writer locks and - may be held by a sleeping process. + These locks provide basic reader-writer type functionality + and may be held by a sleeping process. Currently they are + backed by &man.lockmgr.9;. - &man.lockmgr.9; Lock List + Shared Exclusive Lock List Variable Name Protectees allproc_lock allproc zombproc pidhashtbl nextpid proctree_lock
Atomically Protected Variables An atomically protected variable is a special variable that is not protected by an explicit lock. Instead, all data accesses to the variables use special atomic operations as described in &man.atomic.9;. Very few variables are treated this way, although other synchronization primitives such as mutexes are implemented with atomically protected variables. - - astpending - -
diff --git a/en_US.ISO8859-1/books/developers-handbook/locking/chapter.sgml b/en_US.ISO8859-1/books/developers-handbook/locking/chapter.sgml index e604ef443b..ed32ed61b5 100644 --- a/en_US.ISO8859-1/books/developers-handbook/locking/chapter.sgml +++ b/en_US.ISO8859-1/books/developers-handbook/locking/chapter.sgml @@ -1,333 +1,313 @@ Locking Notes This chapter is maintained by the FreeBSD SMP Next Generation Project. Please direct any comments or suggestions to its &a.smp;. This document outlines the locking used in the FreeBSD kernel to permit effective multi-processing within the kernel. Locking can be achieved via several means. Data structures can be protected by mutexes or &man.lockmgr.9; locks. A few variables are protected simply by always using atomic operations to access them. Mutexes A mutex is simply a lock used to guarantee mutual exclusion. Specifically, a mutex may only be owned by one entity at a time. If another entity wishes to obtain a mutex that is already owned, it must wait until the mutex is released. In the FreeBSD kernel, mutexes are owned by processes. Mutexes may be recursively acquired, but they are intended to be held for a short period of time. Specifically, one may not sleep while holding a mutex. If you need to hold a lock across a sleep, use a &man.lockmgr.9; lock. Each mutex has several properties of interest: Variable Name The name of the struct mtx variable in the kernel source. Logical Name The name of the mutex assigned to it by mtx_init. This name is displayed in KTR trace messages and witness errors and warnings and is used to distinguish mutexes in the witness code. Type The type of the mutex in terms of the MTX_* flags. The meaning for each flag is related to its meaning as documented in &man.mutex.9;. MTX_DEF A sleep mutex MTX_SPIN A spin mutex - MTX_COLD + MTX_RECURSE - This mutex is initialized very early. Thus, it - must be declared via - MUTEX_DECLARE, and the - MTX_COLD flag must be passed to - mtx_init. - - - - - MTX_TOPHALF - - This spin mutex does not disable - interrupts. - - - - - MTX_NORECURSE - - This mutex is not allowed to recurse. + This mutex is allowed to recurse. Protectees A list of data structures or data structure members that this entry protects. For data structure members, the name will be in the form of Dependent Functions Functions that can only be called if this mutex is held. Mutex List Variable Name Logical Name Type Protectees Dependent Functions sched_lock sched lock MTX_SPIN | - MTX_COLD + MTX_RECURSE _gmonparam, cnt.v_swtch, cp_time, curpriority, P_PROFIL XXX, - P_INMEM, - P_SINTR, - P_TIMEOUT, - P_SWAPINREQ XXX, - P_INMEN XXX), - p_prof/, - p_ru/, + statclock), + pscnt, slpque, itqueuebits, itqueues, rtqueuebits, rtqueues, queuebits, queues, idqueuebits, idqueues, switchtime, + switchticks setrunqueue, remrunqueue, mi_switch, chooseproc, schedclock, resetpriority, updatepri, maybe_resched, cpu_switch, - cpu_throw + cpu_throw, + need_resched, + resched_wanted, + clear_resched, + aston, + astoff, + astpending, + calcru, + proc_compare vm86pcb_lock vm86pcb lock - MTX_DEF | - MTX_COLD + MTX_DEF vm86pcb vm86_bioscall Giant Giant MTX_DEF | - MTX_COLD + MTX_RECURSE nearly everything lots callout_lock callout lock - MTX_SPIN + MTX_SPIN | + MTX_RECURSE callfree, callwheel, nextsoftcheck, softticks, ticks
- - Lock Manager Locks + + Shared Exclusive Locks - Locks that are provided via the &man.lockmgr.9; interface - are lock manager locks. These locks are reader-writer locks and - may be held by a sleeping process. + These locks provide basic reader-writer type functionality + and may be held by a sleeping process. Currently they are + backed by &man.lockmgr.9;. - &man.lockmgr.9; Lock List + Shared Exclusive Lock List Variable Name Protectees allproc_lock allproc zombproc pidhashtbl nextpid proctree_lock
Atomically Protected Variables An atomically protected variable is a special variable that is not protected by an explicit lock. Instead, all data accesses to the variables use special atomic operations as described in &man.atomic.9;. Very few variables are treated this way, although other synchronization primitives such as mutexes are implemented with atomically protected variables. - - astpending - -