0% found this document useful (0 votes)
37 views2 pages

Concurrency Control Techniques

DBMS NOTES BCA

Uploaded by

deena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Concurrency Control Techniques

DBMS NOTES BCA

Uploaded by

deena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Concurrency Control Techniques

There are several techniques that can be used to ensure that a schedule is
serializable, including −

 Locking − This technique involves placing locks on specific data items to prevent conflicting
operations from being executed simultaneously.
 Time stamping − This technique involves assigning a unique time stamp to each transaction,
and transactions are executed in order of their time stamp.
 Optimistic concurrency control − This technique involves allowing transactions to be
executed concurrently, but checking for conflicts at commit time.

Example

In the above example, we have two transactions T1 and T2 that are executed
concurrently. T1 reads the value of A and B, increments them by 1, and writes
the new values back to the database. T2 also reads the value of A and B,
increments them by 1, and writes the new values back to the database.

If T1 and T2 are executed in a serial schedule, the final values of A and B will
be 2. But if they are executed concurrently, there is a possibility of a conflict
as both T1 and T2 are trying to update the same values simultaneously. This
can result in an inconsistent state.

To prevent this type of conflict, we can use concurrency control techniques


like locking or time stamping. For example, if we use locking, T1 would
acquire a lock on A and B before reading and updating them, and T2 would
have to wait until T1 releases the lock before it can acquire the lock and execute
its operations. This ensures that T1 and T2 are not executing their operations
on the same data simultaneously and thus avoiding conflict.

Another example of serializability in real life would be in an e-commerce


platform. Two customers, A, and B are trying to purchase the last available
item in a store. If the transactions were executed in a serial schedule, customer
A would purchase the item and customer B would be notified that the item is
out of stock.

But if the transactions were executed concurrently, there is a possibility of a


conflict as both A and B are trying to purchase the same item simultaneously.
To prevent this type of conflict, we can use a technique like time stamping,
where the first customer to click the “purchase” button gets the item and the
other customer is notified that the item is no longer available.

You might also like