




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、Chapter 16 : Concurrency Control Chapter 16: Concurrency ControlLock-Based ProtocolsDeadlock HandlingLock-Based ProtocolsA lock is a mechanism to control concurrent access to a data itemData items can be locked in two modes : 1. exclusive (X) mode. Data item can be both read as well as written. X-lo
2、ck is requested using lock-X instruction. 2. shared (S) mode. Data item can only be read. S-lock is requested using lock-S instruction.Lock requests are made to concurrency-control manager. Transaction can proceed only after request is granted.Lock-Based Protocols (Cont.)Lock-compatibility matrixA t
3、ransaction may be granted a lock on an item if the requested lock is compatible with locks already held on the item by other transactionsAny number of transactions can hold shared locks on an item, but if any transaction holds an exclusive on the item no other transaction may hold any lock on the it
4、em.If a lock cannot be granted, the requesting transaction is made to wait till all incompatible locks held by other transactions have been released. The lock is then granted.Lock-Based Protocols (Cont.)Example of a transaction performing locking: T2: lock-S(A); read (A); unlock(A); lock-S(B); read
5、(B); unlock(B); display(A+B)Locking as above is not sufficient to guarantee serializability.A locking protocol is a set of rules followed by all transactions while requesting and releasing locks. Locking protocols restrict the set of possible schedules.Pitfalls of Lock-Based ProtocolsConsider the pa
6、rtial scheduleNeither T3 nor T4 can make progress executing lock-S(B) causes T4 to wait for T3 to release its lock on B, while executing lock-X(A) causes T3 to wait for T4 to release its lock on A.Such a situation is called a deadlock. To handle a deadlock one of T3 or T4 must be rolled back and its
7、 locks released.Pitfalls of Lock-Based Protocols (Cont.)The potential for deadlock exists in most locking protocols. Deadlocks are a necessary evil.Starvation is also possible if concurrency control manager is badly designed. For example:A transaction may be waiting for an X-lock on an item, while a
8、 sequence of other transactions request and are granted an S-lock on the same item. The same transaction is repeatedly rolled back due to deadlocks.Concurrency control manager can be designed to prevent starvation.The Two-Phase Locking ProtocolThis is a protocol which ensures conflict-serializable s
9、chedules.Phase 1: Growing Phasetransaction may obtain locks transaction may not release locksPhase 2: Shrinking Phasetransaction may release lockstransaction may not obtain locksThe protocol assures serializability. It can be proved that the transactions can be serialized in the order of their lock
10、points (i.e. the point where a transaction acquired its final lock). The Two-Phase Locking Protocol (Cont.)Two-phase locking does not ensure freedom from deadlocksCascading roll-back is possible under two-phase locking. To avoid this, follow a modified protocol called strict two-phase locking. Here
11、a transaction must hold all its exclusive locks till it commits/aborts.Rigorous two-phase locking is even stricter: here all locks are held till commit/abort. In this protocol transactions can be serialized in the order in which they commit.Lock ConversionsTwo-phase locking with lock conversions: Fi
12、rst Phase: can acquire a lock-S on itemcan acquire a lock-X on itemcan convert a lock-S to a lock-X (upgrade) Second Phase:can release a lock-Scan release a lock-Xcan convert a lock-X to a lock-S (downgrade)This protocol assures serializability. But still relies on the programmer to insert the vario
13、us locking instructions.Implementation of LockingA lock manager can be implemented as a separate process to which transactions send lock and unlock requestsThe lock manager replies to a lock request by sending a lock grant messages (or a message asking the transaction to roll back, in case of a deadlock)The requesting transaction waits until its request is answeredThe lock manager maintains
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 體育器材行業環保教育與培訓課程內容開發標準考核試卷
- 交通銀行面試題及答案
- 防范地方保護主義難點分析
- 全國統一大市場的金融支持政策
- 知識產權要素市場整合
- 產業分工協作的優化策略
- 中國歷史期末試題(十)【考試范圍:7-13單元】答案
- 政治一模題目及答案
- 政府會計題目及答案大全
- 2025至2030年中國聲控免提通話電路行業投資前景及策略咨詢報告
- 哇哈哈品牌管理制度
- 千年菩提路解說詞
- 最新纏論基礎知識大全共課件
- SHSG0522023年石油化工裝置工藝設計包(成套技術)內容規定
- 2022年中國重癥患者轉運指南-2
- 中學生日常行為習慣養成課題計劃2
- 懸臂澆筑連續梁梁體鋼筋施工技術交底
- 滬教牛津版小學一至六年級英語單詞匯總(最新)
- 計價格(2002)10號文
- 從銷售員到銷售總監的六門必修課
- 《云南省建筑工程資料管理規程應用指南)(上下冊)
評論
0/150
提交評論