Consider the following schedule on data object Q, whose initial value is 500.…
2024
Consider the following schedule on data object Q, whose initial value is 500. What will be the final value of Q after the last operation?
1. T1: Read(Q)
2. T2: Read(Q)
3. T1: Q = Q + 100
4. T2: Q = Q + 100
5. T2: Write(Q)
6. T1: Write(Q)
- A.
600
- B.
700
- C.
550
- D.
500
Attempted by 335 students.
Show answer & explanation
Correct answer: A
Initial value: Q = 500.
1. T1 reads Q, so local T1 = 500.
2. T2 reads Q, so local T2 = 500. This happens before any transaction writes a new value.
3. T1 computes Q = 500 + 100 = 600 in its local copy.
4. T2 computes Q = 500 + 100 = 600 in its local copy.
5. T2 writes its local value, so database Q becomes 600.
6. T1 writes its local value last, so database Q is overwritten with 600 again.Final value of Q = 600. Therefore, option A is correct.