Understand concurrent scheduling in database
To maintain database consistency we schedule the transaction. Consistency is one of the main properties of database transaction. The main goal of concurrent scheduling is to allow multiple users can access the database without interfering each other. Consider the transaction T1 and T2 that wants to transfer funds from one account to another. T1 transfers $100 from account A to account B. It is defined as
T1:
read(A);
A:=A-100;
write(A);
read(B);
B:B+100;
write(B).
And transaction T2 transfer 10 percent of the balance from account A to account B. It is defined as
T2:
read(A);
temp:=A*0.1;
A: A-temp;
write(A);
read(B);
B:=B+temp;
write(B);
Suppose the current values of account A and B are $1000 and $2000, respectively. When the transaction execute sequentially we call it serial schedule. Serial schedule is not concurrent schedule. We call it just schedule. If two transactions are running concurrently, the operating system may execute one transaction for a little while then perform a context switch and then execute second transaction for some time and then switch back to the first transaction for some time and so on. Concurrent transaction show how a set of transaction executed in a specific time. So we schedule the transaction serially and concurrently. At first I discuss the serial schedule. Serial schedule means the transaction executed serially without interleaving. It means T1 executed first and then T2 executed second or T2 executed first and then T1 executed second correspondingly. So we schedule the two transaction ( T1->T2 ) and ( T2->T1). To understand serial schedule see the picture below.
Now I discuss the concurrent schedule. The idea of concurrent scheduling is to run many transaction concurrently. To do it database system use context switching concept. At first it execute one sub-part of a transaction T1 such as read and then switched to another transaction sub-part and so on. To understand concurrent scheduling see the picture below.
T1:
read(A);
A:=A-100;
write(A);
read(B);
B:B+100;
write(B).
And transaction T2 transfer 10 percent of the balance from account A to account B. It is defined as
T2:
read(A);
temp:=A*0.1;
A: A-temp;
write(A);
read(B);
B:=B+temp;
write(B);
Suppose the current values of account A and B are $1000 and $2000, respectively. When the transaction execute sequentially we call it serial schedule. Serial schedule is not concurrent schedule. We call it just schedule. If two transactions are running concurrently, the operating system may execute one transaction for a little while then perform a context switch and then execute second transaction for some time and then switch back to the first transaction for some time and so on. Concurrent transaction show how a set of transaction executed in a specific time. So we schedule the transaction serially and concurrently. At first I discuss the serial schedule. Serial schedule means the transaction executed serially without interleaving. It means T1 executed first and then T2 executed second or T2 executed first and then T1 executed second correspondingly. So we schedule the two transaction ( T1->T2 ) and ( T2->T1). To understand serial schedule see the picture below.
Now I discuss the concurrent schedule. The idea of concurrent scheduling is to run many transaction concurrently. To do it database system use context switching concept. At first it execute one sub-part of a transaction T1 such as read and then switched to another transaction sub-part and so on. To understand concurrent scheduling see the picture below.
Comments
Post a Comment