1
$\begingroup$

Consider the following variant of the two phase locking protocol. Suppose a transaction $T$ accesses (for read or write operations), a certain set of objects ${O_1,...,O_k}$.

The modified algorithm works as :

Step 1. $T$ acquires exclusive locks to $O_1, . . . , O_k$ in increasing order of their ids.

Step 2. The required operations are performed.

Step 3. All locks are released.

Does this protocol ensure serializability and freedom from deadlock?

Since the locks are being obtained in an increasing order of their ids, the circular wait condition cannot prevail and a deadlock can thus be avoided. But does it ensure serializability? How to argue with respect to the serialization aspect?

$\endgroup$
2
$\begingroup$

The question is not clear about the details, but assuming said resources are always locked-then-accessed sequentially, then a deadlock is not possible to occur. Since the locks are always obtained in the same order, precedence would prevent any cross-lock scenarios. Once a transaction T gained the lock for the first resource then a) it's guaranteed that no other resource ahead will be locked or b) in case a lock L exists ahead then it's guaranteed that the second transaction T' holding the lock L will not try to access resources that are located prior the lock L.

Because the access is being made in a sequential fashion, serialization would be guaranteed a) to individual resources if each resource is unlocked immediately after being accessed or b) to the resource group if all resources are unlocked only when the transaction is completed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.