Write an algorithm for shared and exclusive locking. How does granularity affect this algorithm?
What will be an ideal response?
read_lock(X):
B: if LOCK (X) = "unlocked"
then begin
LOCK (X) = "readlocked";
noOfReads(X) = 1
end
else if LOCK(X) = "readlocked"
then noOfReads(X) = noOf Reads(X) + 1
else begin
wait (until LOCK (X) = "unlocked" and
the lock manager wakes up the transaction);
goto B
end
write_lock (X):
B: if LOCK (X) = "unlocked"
then LOCK (X) = "writelocked"
else begin
wait (until LOCK(X) = "unlocked" and
the lock manager wakes up the transaction);
goto B
end;
unlock_item (X):
if LOCK (X) = "writelocked"
then begin
LOCK (X) = "unlocked";
wakeup one of the waiting transactions, if any
end
else if LOCK(X) = "readlocked"
then begin
noOfReads(X) = noOfReads(X) 1;
if noOfReads(X) = 0
then begin
LOCK (X) = "unlocked";
wakeup one of the waiting transactions, if any
end;
end;
Algorithm 1 Locking and unlocking operations for twomode (readwrite or sharedexclusive)
locks
You might also like to view...
The ____ provides a code template for every event procedure.
A. Code Editor B. Template Editor C. Code Template D. Template Tool
After clicking the Formulas tab to create a formula with values that match conditions, which would you click next to select the function name from the drop down menu?
A. Logical B. Lookup & Reference C. Recently Used D. Insert Function
________ the plan is as important to the recovery success as the planning itself
Fill in the blank(s) with correct word
There is a network looping problem after installing some switches. The switch vendor suggested the use of 802.1d. Which of the following is the MOST probable reason the vendor made this suggestion?
A. It is a rapid version of spanning tree that uses BPDU to detect problems B. It is a regular version of port mirroring that uses hellow packets to detect loops C. It is a simple version of spanning tree that uses BPDU to detect problems D. It is a rapid version of port mirroring that uses BPDU to detect problems