MODULE V Part 3
MODULE V Part 3
2
CONCURRENCY
3
What is Concurrency ?
4
Concurrency Control
● To prevent collisions.
● To prevent errors and inconsistencies in the
database
5
Interleaved &
Parallel
Execution
6
Interleaved Processing
● In multiprogramming operating systems.
● Execute some commands from one process, then
suspend that process and execute some commands
from the next process and so on.
● A process is resumed at the point where it was
suspended whenever it gets its turn to use the
CPU again.
7
Interleaved Processing
8
Parallel Processing
● Multiple CPUs.
9
Need for
Concurrency
Control The Lost Update Problem
10
Consider the
scenario
An airline reservations database in which a record is
stored for each airline flight.
Suppose that transactions T1and T2 are submitted at approximately the same time.
T2 reads the value of X before T1 changes it in the database, and hence the updated value resulting from T1 is lost.
For example, if X = 80 at the start ,N = 5 , and M = 4 , the final result should be X = 79.
In the interleaving of operations, it is X = 84 because the update in T1 that removed the five seats from X was lost.
12
The Temporary Update or Dirty Read Problem
T1 updates item X and then fails before completion, so the system must change X back to its original value.
Before it can do so, however, transaction T2 reads the temporary value of X, which will not be recorded permanently in the
database .
The value of item X that is read by T2 is called dirty data because it has been created by a transaction that has not completed
and committed yet
13
The Incorrect Summary Problem
Transaction T3 is calculating the total number of reservations on all the flights; meanwhile,
transaction T1 is executing.
If the interleaving of operations occurs, the result of T3 will be off by an amount N because T3
reads the value of X after N seats have been subtracted from it but reads the value of Y before
those N seats have been added to it. 14
The Unrepeatable Read Problem
A transaction T reads the same item twice and the item is changed by another
transaction T’ between the two reads.
Hence, T receives different values for its two reads of the same item.
For example, if during an airline reservation transaction, a customer inquiries about seat
availability on several flights. When the customer decides on a particular flight, the
transaction then reads the number of seats on that flight a second time before completing the
reservation, and it may end up reading a different value for the item.
15
THANK YOU
16