10CC - CONCURRENCY CONTROL(CHAPTER 16 Prof Ghandeharizadeh 1 CONCURRENCY CONTROL INTRODUCTION Motivation A dbms is multiprogrammed to increase the

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
09/27/09 Prof. Ghandeharizadeh 1 CONCURRENCY CONTROL (CHAPTER 16)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
09/27/09 Prof. Ghandeharizadeh 2 CONCURRENCY CONTROL INTRODUCTION Motivation: A dbms is multiprogrammed to increase the utilization of resources. While the CPU is processing one transaction, the disk can perform a write operation on behalf of another transaction. However, the interaction between multiple transactions must be controlled to ensure atomicity and consistency of the database. As an example, consider the following two transactions. T 0 transfers 50 from account A to B. T 1 transfers 10% of the balance from A to B. T 0 T 1 read(A) read(A) A=A-50 tmp = A × 0.1 write(A) A = A - tmp read(B) write(A) B=B+50 read(B)
Background image of page 2
09/27/09 Prof. Ghandeharizadeh 3 CONCURRENCY CONTROL INTRODUCTION (Cont…) Assume the balance of A is 1000 and B is 2000. The bank's total balance is 3000. If the system executes T 0 before T 1 then A's balance will be 855 while B's balance will be 2145. On the other hand, if T 1 executes before T 0 then A's balance will be 850 and B's balance will be 2150. However, note that in both cases, the total balance of these two accounts is 3000. In this example both schedules are consistent. A schedule is a chronological execution order of multiple transactions by a system. A serial schedule is a sequence of processing multiple transactions which ensures atomicity of each transaction. Given n transactions, there are n! valid serial schedules. Concurrent execution of multiple transactions, where the instructions of different transactions are interleaved, may result in a non-serial schedule. To illustrate, assuming that a transaction makes a copy of each data item in order to manipulate it, consider the following execution:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
09/27/09 Prof. Ghandeharizadeh 4 CONCURRENCY CONTROL INTRODUCTION (Cont…) T 0 T 1 read(A) A=950 A=A-50 read(A) A=1000 tmp = A × 0.1 tmp=100 A = A - tmp write(A) A=900 read(B) B=2000 A=950 write(A) B=2000 read(B) B=B+50 B=2050 write(B) B=B+tmp write(B) B=2100 The final value of A and B are 950 and 2100, respectively. Note that the sum of these two values is 3050. This means that the bank has lost 50 due to the interleaved execution of instructions.
Background image of page 4
09/27/09 Prof. Ghandeharizadeh 5 CONCURRENCY CONTROL INTRODUCTION (Cont…) In general, given two transactions T i and T j with instructions I i and I j : If I i and I j refer to different data items then their execution order does not matter. If they refer to the same data item Q then the order might be important: 1. I i = read(Q) I j = read(Q) order does not matter 1. I i = read(Q) I j = write(Q) order is important because: (1) if the order is I i , I j then T i does not observe T j 's update
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
09/27/09 Prof. Ghandeharizadeh 6 CONCURRENCY CONTROL INTRODUCTION (Cont…) 1. I i = write(Q) I j = read(Q) order is important because: (1) if the order is I i , I j then T j observes T i 's update (2) if the order is I j , I i then T j does not observe the update of T i 1. I i = write(Q) I j = write(Q) order is important because the value
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/11/2009 for the course CSCI 485 taught by Professor Ghandeharizadeh during the Fall '08 term at USC.

Page1 / 22

10CC - CONCURRENCY CONTROL(CHAPTER 16 Prof Ghandeharizadeh 1 CONCURRENCY CONTROL INTRODUCTION Motivation A dbms is multiprogrammed to increase the

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online