Concept of Schedule
Schedule
- A schedule is a collection of several transactions that can be executed in a predefined order as a single unit.
Schedule may combine the operations of one transaction with other transaction. These operations must be in same sequence as they occur in their individual transactions.
- Schedule is necessary in a situation when a system has several transactions which are going to be perfonned on same database object. If those transactions are execttted in parallel, affect the result of th-: transaction.
For examiJle they may
After execution of both transactions M holds $200arrd N holds$1300.
Schedule 2 : Serial schedule for T2 followed by T1
- Consider transaction T1 and T2 are present in the system, and both use the values of account A
·commonly. If one transaction is updating the values which the other transaction is accessing, then the order of these two transactions wil! change the result of second transaction. Hence a schedule is created to execute the transactions.
- Depending on the arrangement of these transactions, schedule can be divided into two types : Serial schedule and concurrent schedule.
Syllabus Topic: Serial Schedule
4.5.2 Types of Schedule
(A) Serial Schedule
0 1n seriai schedule all 'the transactions in the schedule are executed one after another. Operations of different transactions are not interspersed with each other.
o For example, account M has $500 and account N has $1000 initially. Transaction Tl transfers $200 from account M to ij and Transaction T2 transfers $100 from aC:count M to N. T1 and T2 can be scheduled in two ways for·executiOn:
Schedule I : Serial schedule for T, fo!lowed by T, After execution of both transactions M holds $200 and N holds $1300.
(B) Concurrent Schedule
Concurrent schedule is a schedule where, several transactions are executed simultaneously. The operations of one transaction can be mixed with operations of other transaction.
Schedule3: Concurrent schedule for T1 and T2
t Read(M);
'I
M=M-100;
Write{M);
r Read(N);
N=N+IOO;
Write(N);
After execution of both transactions M holds $200 and N holds $ 1300.
In this example concurrent schedule also provides same result as the above two serial schedule provides. But not all the concurrent schedules provide result in consistent state.
Advantages of Concurrent Execution of Transactions
Though it is difficult to ensure the isolation while executing transactions concurrently, it has different advantages as follows :
- Reduced waiting time
System has several transactions which may be short or long. In serial execution of transaction, short transactions need to wait more when long
·transactions are being processed. If these
(A) Write-Write conflicts
o Here both the transactions T1 and T2 read transactions executed concurrently, it will reduce the waiting time.
initial values A=IOOO]. of data item (A) [assume
- Increased average response time
.In concurrent execution, the multiple transactions executes concurrently by sharing various system resources, the waiting time get decreas because of which the response time automatically get increased.
Improved resource utilization Number of transactions run concurrently in the
_system, in which if any transaction needs t<f. wait for some operations to complete, the CPU has ability to switch to other transaction, so the CPU can be utilized :in efficient way. It will no more in ideal state.
- Throughput
Throughput indicates the n Jriber of transaction processed in a time unit. 1/s several transactions
get executed simultaneously _in the system. Due to efficient resource utilization it will produce their outputs in less amount of time. So numbers of transaction completed is more as compare to serial execution of transactions which will increase the throughput of the system. This leads to increase in system performance.
o Initially T2 adds 500 to A and write new value 1500 of A into database.
o Now T1 update the initial value of A(I°OOO) to
1050 and write it ill' the database.
o In between these transactions, the value updated by transaction T2 is lost.
o Thus write-write conflicts affects lost update on database.
(Bl Read-Write conflicts
o Transaction TI and T2 reads initial value of i
A (1000).
o TI updates value of A to 15_00 by a,dding 500
to it and writes it into database and commit.
o Now T2 again read the value of A which is now 1500.
I 4.5.4 Problems Occur in Concurrent
o Here transaction T2 reads two different values Execution of Transaction
The problem occurs when two transactions are dealing with same data item if one of the transactions performs write operation. If any transaction contains following situations then the conflicts are occurred:
of same data element A.
o This is read-write conflict.
Comments
Post a Comment