Complete the code to acquire a shared lock on a data item.
lock.acquire([1]);In lock-based protocols, S stands for a shared lock, which allows multiple transactions to read a data item concurrently.
Complete the code to release a lock on a data item.
lock.[1]();The release method frees the lock held on a data item so other transactions can access it.
Fix the error in the code to check if a lock is compatible with a shared lock.
if (lock.type == '[1]') { allowRead(); }
Shared locks (S) are compatible with other shared locks, allowing concurrent reads.
Fill both blanks to implement strict two-phase locking protocol.
beginTransaction(); acquireLock([1]); // perform operations [2](); commitTransaction();
Strict 2PL requires acquiring an exclusive lock (X) and releasing it only at commit time using releaseLock.
Fill all three blanks to create a lock table entry for a transaction.
lockTable[[1]] = { type: [2], owner: [3] };
A lock table entry maps a dataItem to its lockType and the transactionId that owns the lock.