in Databases
503 views
1 vote
1 vote
given schedule s: R2A W1B W1C R3B R2B R1A C1 R2C C2 W3A C3

How should I approach to above problem when  LOCKS ARE NOT  GIVEN and  to find if s is 2PL ?
in Databases
503 views

1 Answer

2 votes
2 votes
try inserting locks such that before read u need S-lock on that variable and before Write u need X-lock on that variable if u get combination of locks which follows 2PL i.e. after unlocking a lock transaction won’t acquire another lock then it follows 2PL.

NOTE:- normal 2PL doesn’t support upgrade or downgrade so if u need to read and later write on variable ‘A’ then u have to acquire X-lock(A) before read since you won’t be able to upgrade from S-lock to X-lock

4 Comments

I can put unlock(B) and unlock(C) after unlock(A) in T1. correct me @Arbaz__Malik

0
0
edited by

@BHOJARAM NO you can’t. because we need to read B in T2 and T3 before T1 execute Read(A) so if we don’t leave X-lock on B then T2 and T3 can’t acquire S-lock on B and can’t proceed. But You can unlock(C) after unlock(A) in T1 as Read(C) is performed by T2 after T1 execute commit.

1
1

Thanx @Arbaz__Malik.... 

0
0

Related questions