Solved MBA IT Assignment and Notes

Full width home advertisement

Post Page Advertisement [Top]

What do you mean by Shared Lock and Exclusive lock? Describe briefly two phase locking protocol?
 Answer:

Shared Locks:

 It is used for read only operations, i.e., used for operations that do not change or update the data. E.G., SELECT statement;
Shared locks allow concurrent transaction to read (SELECT) a data. No other transactions can modify the data while shared locks exist. Shared locks are released as soon as the data has been read.

Exclusive Locks: 


Exclusive locks are used for data modification operations, such as UPDATE, DELETE and INSERT. It ensures that multiple updates cannot be made to the same resource simultaneously. No other transaction can
read or modify data when locked by an exclusive lock.  Exclusive locks are held until transaction commits or rolls back since those are used for write operations.

There are three locking operations: read_lock(X), write_lock(X), and unlock(X). A lock associated with an item X, LOCK(X), now has three possible states: "read locked", "write-locked", or "unlocked". A read-locked item is also called share-locked, because other transactions are allowed to read the item, whereas a write-locked item is called exclusive-locked, because a single transaction exclusive holds the lock on the item.

The Two Phase Locking Protocol

The two phase locking protocol is a process to access the shared resources as their own without creating deadlocks. This process consists of two phases.
1.  Growing Phase: In this phase the transaction may  acquire lock, but may not release any locks. Therefore this phase is also called as resource acquisition activity.
2.  Shrinking phase: In this phase the transaction may release locks, but may not acquire any new locks. This includes the modification of data and release locks. Here two activities are grouped together to form second phase.

In the beginning, transaction is in growing phase. Whenever lock is needed the transaction acquires it. As the lock is released, transaction enters the next phase and it can stop acquiring the new lock request.

Strict two phase locking:

In the two phases locking protocol cascading rollback are not avoided. In order to avoid this slight modification are made to two phase locking and called strict two phase locking. In this phase all the locks are acquired by the transaction are kept on hold until the transaction commits.
Deadlock & starvation: In deadlock state there exists, a set of transaction in which every transaction in the set is waiting for another transaction in the set.

Suppose there exists a set of transactions waiting:
{T1, T2, T3,……………….., Tn) such that T1 is waiting for a data item existing in T2, T2 for T3 etc… and Tn is waiting of T1.    In this state none of the transaction will progress.

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib