in Databases
21,241 views
64 votes
64 votes

Consider the following two phase locking protocol. Suppose a transaction $T$ accesses (for read or write operations), a certain set of objects $\{O_1,\ldots,O_k \}$. This is done in the following manner:

  • $\text{Step 1}$. $T$ acquires exclusive locks to $O_1,\ldots,O_k$ in increasing order of their addresses.
  • $\text{Step 2}$. The required operations are performed .
  • $\text{Step 3}$. All locks are released

This protocol will

  1.  guarantee serializability and  deadlock-freedom 
  2.  guarantee neither serializability nor deadlock-freedom 
  3.  guarantee serializability but not deadlock-freedom  
  4.  guarantee deadlock-freedom but not serializability.
in Databases
21.2k views

4 Comments

it is same like preventing deadlock for circular wait  in operating system
5
5
Here the operation is acquiring all the  locks first and then it is starting the transaction ,So it is a conservative 2pl and and this conservative 2pl guarantees serializability and also deadlock free as it gets what all needed before hand
0
0
0
0

4 Answers

102 votes
102 votes
Best answer

Two Phase Locking protocol is conflict serializable. So this is a modified version of the basic $2PL$ protocol, So serializabilty should be guaranteed.. and we can get a serializable scheduling by ordering based on Lock points(same as in basic $2PL$
)..
Now in Step $1,$ exclusive locks are aquired to $O_1,O_2,O_3$.... in increasing order of addresses..since it is mentioned as exclusive lock, only one transaction can lock the object..
Due to acquiring of locks based on ordering of addresses.. and locks aren't released until the transaction completes its operation.. we can prevent the circular wait condition, and hence making it deadlock free.

So, the answer should be (A) guarantees serializability and deadlock freedom

edited by

4 Comments

Here context switch can not occur ?
0
0

@raviteja yakkaladevi that won’t happen. Because when V comes in, V would also want to acquire lock on O1 first, since it’s given that a transaction “acquires exclusive locks to O1,.....,Ok in increasing order of their addresses” – compulsorily. 

So V will not be able to acquire lock on O1 since it has already been occupied by T.

 $\Rightarrow$ V will not be able to acquire lock on O2, O3 and so on.  

0
0

  it only cares about acquiring of all locks before proceeding/executing, it has no condition on when can the locks be freed. so it does not ensure any recoverability. 

0
0
12 votes
12 votes
It is Conservative 2PL Protocol which ensures Deadlock Freedom. Therefore A is the correct answer.

4 Comments

But we do require locks when we start.Lets us say that the protocol  mentioned in problem is some X ,which is a variation of 2PL.

Now if X allows something => conservative will also allow.

However converse will not hold.

So,we can say that it is subset of conservative 2PL.Just extra thing:p.Not required in problr,
0
0
We can say that,but that is not the same thing,by definition they are different and more importantly they will be implemented differently,suppose you implement a schedule i.e rigorous 2pl so can you say that you also implemented conservative 2pl(no,because you have to write different set of programs for that).
0
0

YES, in conservative-2PL no locks will be acquired until all the needed-resources are available at same time.

Here according to the problem statement, we are acquiring locks based on increasing order of addresses even if 1 resource out of "n"-needed is available.

So, Given schedule is NOT A CONSERVATIVE 2-PL.

1
1
6 votes
6 votes
A is correct option .....

3 Comments

yup A because there is only 1 transaction ..no any problem of serializablity and deadlock !
8
8
nope bro it is  general rule defined for any transaction.
2
2
This is conservative 2PL scheduler with partial ordering of data items.

 

Conservation 2pl ensure both deadlock free and conflict serializatibily.

Partial ordering too ensures deadlock free.

So the resulting schedule(not because it is having only one transaction) will be serializable and deadlock free.
0
0
1 vote
1 vote
EVEN THOUGH THERE IS MORE THAN ONE LOCKS EITHER EXCLUSIVE OR ANY GROWING LOCKS AND RELESING LOCKS DOES NOT OCCUR  DEADLOCK  SO OPTION A IS CORRECT
by

1 comment

moved by
OPTION A IS APPROPIATE ONE
0
0
Answer:

Related questions