in Databases edited by
929 views
0 votes
0 votes

Assume transaction $A$ holds a shared lock $R.$ If transaction $B$ also requests for a shared lock on $R.$ It will

  1. result in deadlock situation
  2. immediately be granted
  3. immediately be rejected
  4. be granted as soon as it is released by $A$
in Databases edited by
929 views

1 Answer

2 votes
2 votes

Shared locks exist when two transactions are granted read access. One transaction gets the shared lock on data and when the second transaction requests the same data it is also given a shared lock. Both transactions are in a read-only mode,

Transaction hold shared lock on data item A .So any number of transaction can read that the data from the requesting item using shared locking .So transaction B request will immediately granted.

So option B is correct.

LOCK SHARED EXCLUSIVE
SHARED YES NO
EXCLUSIVE NO NO

 

2 Comments

why noT      D

can you give proper explanation
0
0
D is not right because shared locks can be accessed by multiple transactions.

The reason is because shared locks are used when read operation needs to be performed. While exclusive locks are used when both read and write operation need to be performed.

If multiple transaction simultaneously read same data then there won’t be any inconsistency, But when write operation is simultaneous then you have problems like dirty read or/and blind write.

So the above justification concludes that shared locks can be simultaneously accessed but exclusive locks aren’t.
0
0
Answer:

Related questions