⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dead.so

📁 berkeley db 4.6.21的源码。berkeley db是一个简单的数据库管理系统
💻 SO
字号:
m4_comment([$Id: dead.so,v 10.21 2005/12/02 17:27:50 alanb Exp $])m4_ref_title(Locking Subsystem,    Deadlock detection, @deadlocks, lock/stdmode, lock/timeout)m4_p([dnlPractically any application that uses locking may deadlock.  Theexceptions to this rule are when all the threads of control accessingthe database are read-only or when the m4_cam product is used; them4_cam product guarantees deadlock-free operation at the expense ofreduced concurrency.  While there are data access patterns that aredeadlock free (for example, an application doing nothing but overwritingfixed-length records in an already existing database), they areextremely rare.])m4_p([dnlWhen a deadlock exists in the system, all the threads of controlinvolved in the deadlock are, by definition, waiting on a lock.  Thedeadlock detector examines the state of the lock manager and identifiesa deadlock, and selects one of the lock requests to reject.  (Seem4_link(M4RELDIR/ref/lock/config, [Configuring locking]) for adiscussion of how a participant is selected).  The m4_ref(lock_get) orm4_ref(lock_vec) call for which the selected participant is waiting thenreturns a m4_ref(DB_LOCK_DEADLOCK) error.  When using the m4_db accessmethods, this error return is propagated back through the m4_db databasehandle method to the calling application.])m4_p([dnlThe deadlock detector identifies deadlocks by looking for a cycle inwhat is commonly referred to as its "waits-for" graph.  More precisely,the deadlock detector reads through the lock table, and reviews eachlock object currently locked.  Each object has lockers that currentlyhold locks on the object and possibly a list of lockers waiting for alock on the object.  Each object's list of waiting lockers defines apartial ordering.  That is, for a particular object, every waitinglocker comes after every holding locker because that holding locker mustrelease its lock before the waiting locker can make forward progress.Conceptually, after each object has been examined, the partial orderingsare topologically sorted.  If this topological sort reveals any cycles,the lockers forming the cycle are involved in a deadlock.  One of thelockers is selected for rejection.])m4_p([dnlIt is possible that rejecting a single lock request involved in adeadlock is not enough to allow other lockers to make forward progress.Unfortunately, at the time a lock request is selected for rejection,there is not enough information available to determine whether rejectingthat single lock request will allow forward progress or not.  Becausemost applications have few deadlocks, m4_db takes the conservativeapproach, rejecting as few requests as may be necessary to resolve theexisting deadlocks.  In particular, for each unique cycle found in thewaits-for graph described in the previous paragraph, only one lockrequest is selected for rejection.  However, if there are multiplecycles, one lock request from each cycle is selected for rejection.Only after the enclosing transactions have received the lock requestrejection return and aborted their transactions can it be determinedwhether it is necessary to reject additional lock requests in order toallow forward progress.])m4_p([dnlThe m4_ref(db_deadlock) utility performs deadlock detection by callingthe underlying m4_db m4_refT(lock_detect) at regular intervals(m4_ref(lock_detect) runs a single iteration of the m4_db deadlockdetector).  Alternatively, applications can create their own deadlockutility or thread by calling the m4_refT(lock_detect) directly, or byusing the m4_refT(dbenv_set_lk_detect) to configure m4_db toautomatically run the deadlock detector whenever there is a conflictover a lock.  The tradeoffs between using the m4_ref(lock_detect) andm4_refT(dbenv_set_lk_detect)s is that automatic deadlock detection willresolve deadlocks more quickly (because the deadlock detector runsas soon as the lock request blocks), however, automatic deadlockdetection often runs the deadlock detector when there is no need forit, and for applications with large numbers of locks and/or where manyoperations block temporarily on locks but are soon able to proceed,automatic detection can decrease performance.])m4_page_footer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -