Samstag, 7. Mai 2011

CS6223 愛國教育,兩敗俱傷

Wan Chin: 愛國教育,兩敗俱傷




愛國教育得到的是對中共的憎恨,對香港的捨棄,正是兩敗俱傷。 香港的政治動員力,並非來自愛中共,而是來自愛香港,愛一個基礎優良而奮力前進的香港。



Distributed Systems
Tutorial on transaction processing

1. a) What is a transaction?
See definition in lecture notes.

b) Why might the execution of transactions interleave with each other?
Transactions are submitted by client programs from different sites (each transaction operation is an RPC). Transactions from different clients are concurrent.

2. A server manages data items a¬1, a2, …, an. Transactions T and U are as follows, read(i) returns value of ai, write(i, val) assigns val to ai:

read(j); read(k);
read(i); write(i,55);
write(j, 44); read(j);
write(i,33); write(k, 66);
(a) give 3 serially equivalent interleavings of T and U.
(b) give an example of “lost update” by interleaving T and U.
(c) give an example of “inconsistent retrievals”.

Answer: see lecture notes
3. Two phase locking requires that once a transaction has released a lock on a data item, it is not allowed to obtain any more locks.
(a) Give an example to explain why the two phases of locking are required to ensure serial equivalence.
(b) Suppose two types of lock, read-lock and write-lock, are used. Since read-locks are compatible with each other, do you think a read-only transaction can release read-lock on a data item immediately after a read operation?

a) If we use the simple locking method (NOT 2Phase locking), the lock on a data item will be released immediately after the completion of a read or write operation. Another transaction could obtain the lock on this data item and access the data. Therefore, non-serializability could occur.

By using 2Phase locking, the above situation will not happen. The lock on a data item will not be released until this transaction doesn’t access data anymore.

b) no. read-only transactions still need to hold the lock on all data items until the transactions don’t access data anymore.
See the “inconsistent retrieval” example, where the “retrieval” transaction consists of only read operations. If 2Phase locking is not followed, read operations of the transaction may read inconsistent data.

Keine Kommentare: