|
Distributed Computing ![]() This website demonstrates using wikis as teaching and learning tool. The course instructor is also happy to share the teaching materials here with those who find it readable. |
ConcurrencyControlConcurrency Control of Transactions - 2PL
T1: y = read(k);
T2: x = read(i);
U1: write(i,33);
T3: write(j,22);
U2: write(j,44);
U1: write(i,33);
T1: y = read(k);
T2: x = read(i);
U2: write(j,44);
T3: write(j,22);
T1: y = read(k);
T2: x = read(i);
T3: write(j,22);
U1: write(i,33);
U2: write(j,44);
T1: y = read(k);
U1: write(i,33);
U2: write(j,44);
T2: x = read(i);
T3: write(j,22);
Concurrency Control of Transactions - OCC
T’s read(i) is compared with writes of overlapping committed transactions, so Transaction T is OK (as U has not yet committed).
Transaction U is OK as no read operations involved.
Transaction U is OK as no read operations involved.
T’s read(i) is compared with writes of overlapping committed transactions (U’s write(i)), so Transaction T FAILS.
T’s write(j) is compared with reads of overlapping active transactions (U), so Transaction T is OK.
U’s write(i) is compared with reads of overlapping active transactions (none), so Transaction U is OK (as T is no longer active).
U’s write(i) is compared with reads of overlapping active transactions (T’s read(i)), so Transaction U FAILS.
T’s write(j) is compared with reads of overlapping active transactions (none), so transaction T is OK.
Concurrency Control of Transactions
In TSO, the time at which a transaction starts is associated with the transaction, and is recorded by every object involved with each operation invoked by the transaction. One serializable order is imposed on the operations by the time-stamp order. Thus, if transaction T2 attempts to invoke an operation that conflicts with an operation already started by transaction T1, and the time-stamp of T2 is earlier than that of T1, then T2 is aborted.
Deadlock detection and prevention in distributed systemsWait-die and wound-wait are two practical algorithms for distributed deadlock prevention.
When a process is about to block waiting for a resource that another process is using, a higher priority is given to an order process rather than a young one.
Advantage: no process is killed. Disadvantage: a younger process may need to wait for a long time to complete its execution.
In (1), The process with transaction timestamp 64 waits for the younger process. In (2), The process with transaction timestamp 64 preempts the resource from the younger one (timestamp 82) and the younger one has to wait.
It is because if a process holds more than one resource, it is impossible to identify the process is old or young and thus it cannot conclude what action should be taken.
Consider a process wants to hold two resources. One resource is held by a younger process and another resource is held by an older process. For wait-die algorithm, it is meaningless to wait for the younger process and die for the older process at the same time. Also for wound-wait algorithm, it cannot take the advantage of preempting the younger process because the process has to wait for the older process.
Deadlock prevention is to add an algorithm for transaction to follow. It may result in significant overhead and some transactions may abort to prevent a deadlock occurs. In deadlock avoidance, we do not touch transactions but resources. We want to take care of the distribution of the resources and avoid deadlocks by computing when they will happen.
|