Presentation is loading. Please wait.

Presentation is loading. Please wait.

Concurrency Control 18.1: Schedules By Cancheevaram Kuppuswamy JaiSarvanan ID: 209.

Similar presentations


Presentation on theme: "Concurrency Control 18.1: Schedules By Cancheevaram Kuppuswamy JaiSarvanan ID: 209."— Presentation transcript:

1 Concurrency Control 18.1: Schedules By Cancheevaram Kuppuswamy JaiSarvanan ID: 209

2 Agenda What is Concurrency control? –What are Transactions? –Need for transactions? –How do they operate? Need for concurrency control? Schedules –Serial –Serializable Notation for Transactions and Schedules

3 Concurrency control The purpose of assuring that transactions preserve consistency when executing simultaneously is called concurrency control. The major theme of concurrency control is methods for forcing transactions to execute concurrently only in ways that make them appear to run one-at-a-time.

4 Transactions Transactions prevents the database state from becoming inconsistent. Serializability: one function executes completely before any other function begins. Atomicity: either all operations are done or neither is done. A transaction is a collection of one or more operations on the database that must be executed atomically and in serializable manner.

5 How transactions operate? 1.For a transaction to read a database element, that element must first be brought to a main-memory buffer(s), it is not already there. This is performed by the Buffer Manager. 2.Then, the contents of the buffer(s) can be read by the transaction into its own address space. 3.Writing of a new value for a database element by a transaction follows the reverse route.

6 Notation 1.INPUT(X): Copy database element X to a memory buffer. 2.READ(X,t): Assign the value of X (present in the memory buffer) to local variable t. 3.WRITE(X,t): Copy the value of t to X in the buffer. Note: If X is not present in the memory buffer, then INPUT is executed before performing READ or WRITE 4. OUTPUT(X): Copy the block containing X from its buffer to disk.

7 Need for concurrency control? Though transactions individually preserve the correctness of the state, Interactions among transactions can cause the state of the database to become inconsistent. When transactions run concurrently with other transactions, the correctness principle does not apply. Correctness principle: If a transaction executes in the absence of any other transactions, and it starts with the database in a consistent state, then the database is also in a consistent state when the transaction ends.

8 Schedules A schedule is a time-ordered sequence of the important read and write actions that takes place in the main- memory buffer. Operation: As transactions request reads and writes of database element, these requests are passed to the scheduler. Scheduler calls the buffer manager if the desired element is not in the buffer, either immediately or delay the request. Since different transactions can access a single memory buffer, when considering concurrency, only the READ and WRITE actions and their orders are important and we shall ignore the INPUT and OUTPUT actions.

9 Example: Consistency constraint is A=B T1T2 READ(A,t)READ(A,s) t := t + 100s := s*2 WRITE(A,t)WRITE(A,s) READ(B,t)READ(B,s) t := t + 100s := s*2 WRITE(A,t)WRITE(A,s)

10 Serial Schedules: T1T2AB 25 READ(A,t) t:=t+100 WRITE(A,t) READ(B,t) t:=t+100 WRITE(B,t) 125 READ(A,s) s:=s*2 WRITE(A,s) READ(B,s) s:=s*2 WRITE(B,s) 250

11 Serializable Schedules: T1T2AB 25 READ(A,t) t:=t+100 WRITE(A,t) READ(A,s) s:=s*2 WRITE(A,s) 125 250 READ(B,t) t:=t+100 WRITE(B,t) READ(B,s) s:=s*2 WRITE(B,s) 125 250

12 A nonserializable schedule: T1T2AB 25 READ(A,t) t:=t+100 WRITE(A,t) READ(A,s) s:=s*2 WRITE(A,s) 125 250 READ(B,t) t:=t+100 WRITE(B,t) READ(B,s) s:=s*2 WRITE(B,s)50 150

13 Notation: –The transactions can be written as T1: r1(A); w1(A); r1(B); w1(B); T2: r2(A); w2(A); r2(B); w2(B); –The serializable schedule of T1 and T2 can be written as r1(A); w1(A); r2(A); w2(A); r1(B); w1(B); r2(B); w2(B);

14 Thank you


Download ppt "Concurrency Control 18.1: Schedules By Cancheevaram Kuppuswamy JaiSarvanan ID: 209."

Similar presentations


Ads by Google