This chapter describes how to control concurrent execution in a database, in order to



Download 0.84 Mb.
View original pdf
Page3/14
Date28.01.2021
Size0.84 Mb.
#55710
1   2   3   4   5   6   7   8   9   ...   14
4480
4480
Answer:
16.2
Consider the following two transactions:
T
31
: read(A);
read
(B);
if A = 0 then B := B + 1;
write
(B).
T
32
: read(B);
read
(A);
if B = 0 then A := A + 1;
write
(A).
Add lock and unlock instructions to transactions T
31
and T
32
, so that they observe the two-phase locking protocol. Can the execution of these transactions result in a deadlock?
Answer:
a.
Lock and unlock instructions:
T
31
: lock-S(A)
read
(A)
lock-X
(B)
read
(B)
if A = 0
then B := B + 1
write
(B)
unlock
(A)
unlock
(B)
T
32
: lock-S(B)
read
(B)
lock-X
(A)
read
(A)
if B = 0
then A := A + 1
write
(A)
unlock
(B)
unlock
(A)
b.
Execution of these transactions can result in deadlock. For example, consider the following partial schedule:
mywbut.com


T
31
T
32
lock-S
(A)
lock-S
(B)
read
(B)
read
(A)
lock-X
(B)
lock-X
(A)
The transactions are now deadlocked.
16.3
What benefit does strict two-phase locking provide What disadvantages result bAnswer:bBecause it produces only cascadeless schedules, recovery is very easy.
But the set of schedules obtainable is a subset of those obtainable from plain two phase locking, thus concurrency is reduced.
16.4
What benefit does rigorous two-phase locking provide How does it compare with other forms of two-phase locking?
Answer:
Rigorous two-phase locking has the advantages of strict PL. In addition it has the property that for two conflicting transactions, their commit order is their serializability order. In some systems users might expect this behavior.
16.5
Most implementations of database systems use strict two-phase locking. Suggest three reasons for the popularity of this protocol.
Answer:
It is relatively simple to implement, imposes low rollback overhead because of cascadeless schedules, and usually allows an acceptable level of concurrency.
16.6
Consider a database organized in the form of a rooted tree. Suppose that we insert a dummy vertex between each pair of vertices. Show that, if we follow the tree protocol on the new tree, we get better concurrency than if we follow the tree protocol on the original tree.
Answer:
The proof is in Buckley and Silberschatz, Concurrency Control in
Graph Protocols by Using Edge Locks Proc. ACM SIGACT-SIGMOD Symposium on the Principles of Database Systems, 1984.
16.7
Show by example that there are schedules possible under the tree protocol that are not possible under the two-phase locking protocol, and vice versa.
Answer:
Consider the tree-structured database graph given below.
c
A
c
B
c
C
Schedule possible under tree protocol but not under 2PL:
mywbut.com


T
1
T
2

Download 0.84 Mb.

Share with your friends:
1   2   3   4   5   6   7   8   9   ...   14




The database is protected by copyright ©ininet.org 2024
send message

    Main page