Modify the data structures for multiple-mode locks and the algorithms for read_lock(X), write_lock(X), and unlock(X) so that upgrading and downgrading of locks are possible. (Hint: The lock needs to keep track of the transaction id(s) that hold the lock, if any.)

What will be an ideal response?


We assume that a List of transaction ids that have read-locked an item is maintained, as
well as the (single) transaction id that has write-locked an item. Only read_lock and
write_lock are shown below.

```
read_lock (X, Tn):
B: if lock (X) = "unlocked"
then begin lock (X) <- "read_locked, List(Tn)";
no_of_reads (X) <- 1
end
else if lock(X) = "read_locked, List"
then begin
(* add Tn to the list of transactions that have read_lock on X *)
lock (X) <- "read_locked, Append(List,Tn)";
no_of_reads (X) <- no_of_reads (X) + 1
end
else if lock (X) = "write_locked, Tn"
(* downgrade the lock if write_lock on X is held by Tn itself *)
then begin lock (X) <- "read_locked, List(Tn)";
no_of_reads (X) <- 1
end
else begin
wait (until lock (X) = "unlocked" and
the lock manager wakes up the transaction);
goto B;
end;
write_lock (X,Tn);
B: if lock (X) = "unlocked"
then lock (X) <- "write_locked, Tn"
else
if ( (lock (X) = "read_locked, List") and (no_of_reads (X) = 1)
and (transaction in List = Tn) )
(* upgrade the lock if read_lock on X is held only by Tn itself *)
then lock (X) = "write_locked, Tn"
else begin
wait (until ( [ lock (X) = "unlocked" ] or
[ (lock (X) = "read_locked, List") and (no_of_reads (X) = 1)
and (transaction in List = Tn) ] ) and
the lock manager wakes up the transaction);
goto B;
end;
```

Computer Science & Information Technology

You might also like to view...

You have used Internet search engines. List the URL of your favorite search engine and three reasons why you prefer it to others. Compare your reasons with three other classmates. Make note of any commonalties among the reasons and relate your answers to the goals of HCI design.

What will be an ideal response?

Computer Science & Information Technology

In addition to the axioms for a programming language, it must also be shown that the program ______ in order to verify the correctness of a program.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Forms and reports can be easily added to the form by dragging the object from the Navigation Pane to the [Add New] button; therefore, it is important to be able to see your Navigation Pane as you work on the navigation form

Indicate whether the statement is true or false

Computer Science & Information Technology

In your role as a consultant for people buying new computer systems, you always work hard to stay abreast of the latest memory requirements for your users. ? Another client is installing her new memory modules today. Which of the following is an instruction or piece of advice you give her? a. Leave her computer plugged into the power source.c. If she is upgrading a laptop, leave the laptop battery in.b. Wear an static wristband to divert static electricity to the computer.d. If she is upgrading a laptop, she may be able to locate the slots for the memory modules through an access panel.

What will be an ideal response?

Computer Science & Information Technology