Professional Documents
Culture Documents
3
• A number of concurrency control techniques – to ensure
the noninterference or isolation property
5
• Most frequently used schemes are
– Two-phase locking and snapshot isolation.
6
Lock-Based Protocols
• One way to ensure isolation is to require that data
items be accessed in a mutually exclusive manner;
7
Locks
• There are various modes in which a data item may be
locked.
9
Compatibility function
• Suppose a transaction Ti requests a lock of mode A on
item Q
11
• Shared mode is compatible with shared mode, but not
with exclusive mode.
13
• Ti is made to wait until all incompatible locks held by
other transactions have been released.
Unlocking is delayed
to the end of the
transaction.
17
Transaction T3 (transaction T1 with unlocking Transaction T4 (transaction T2 with unlocking
delayed). delayed).
18
Deadlock
20
Conflict Serializability
Two schedules are said to be conflict equivalent if all the
conflicting operations in both the schedule get executed in the
same order.
21
View Serializability
22
Granting of Locks
• The lock can be granted
– When a transaction requests a lock on a data item in a
particular mode,
– No other transaction has a lock on the same data item in a
conflicting mode
24
The Two-Phase Locking Protocol
• Precedes
– Ti precedes Tj in S, (Ti →Tj)
– if there exists a data item Q such that
– Ti has held lock mode A on Q, and
– Tj has held lock mode B on Q later, and
– comp(A,B) = false.
25
The Two-Phase Locking Protocol
Legal
Ensures