Types of locks, Database Management System

Assignment Help:

Types of Locks

There are two necessary types of locks:

  • Binary lock: This locking mechanism has two states for to a data item: locked or unlocked
  • Multiple-mode locks: In this locking type every data item can be in 3 states read locked or shared locked, write locked or exclusive locked or unlocked.

Let us first take an instance for binary locking and describes how it solves the concurrency related troubles. Let us reconsider the transactions T1 and T2 for this purpose; though we will add to needed binary locks to them.

Schedule

T1

T2

Lock X

Lock X

 

Read X

Read X

 

Subtract 100

Subtract 100

 

Write X

Write X

 

Unlock X

Unlock X

 

Lock X

 

Lock X

Lock Y

 

Lock Y

Read X

 

Read X

Read Y

 

Read Y

Display X+Y

 

Display X+Y

Unlock X

 

Unlock X

Unlock Y

 

Unlock Y

Lock Y

Lock Y

 

Read Y

Read Y

 

Add 100

Add 100

 

Write Y

Write Y

 

Unlock Y

Unlock Y

 

 

 

 

                                                         Figure: An incorrect locking implementation

Does the locking as completed above solve the problem of concurrent transactions? No the similar problems still remains. Try working with the old value. Therefore, locking should be completed with some logic in order to make sure that locking results in no concurrency related problem. One such answer is given below:

Schedule

T1

T2

Lock X

Lock X

 

Lock Y

Lock Y

 

Read X

Read X

 

Subtract 100

Subtract 100

 

Write X

Write X

 

Lock X (issued by

T2)

Lock X: denied as T1 holds the lock.

The transaction T2 Waits and T1 continues.

Read Y

Read Y

 

Add 100

Add 100

 

Write Y

Write Y

 

Unlock X

Unlock X

 

 

The lock request of T2 on X can now

be granted it can resumes by locking X

Unlock Y

Unlock Y

 

Lock Y

 

Lock Y

Read X

 

Read X

Read Y

 

Read Y

Display X+Y

 

Display X+Y

Unlock X

 

Unlock X

Unlock Y

 

Unlock Y

                                                              Figure: A correct but restrictive locking implementation

Therefore, the locking as above when you get all the locks at the starting of the transaction and release them at the end ensures that transactions are implemented with no concurrency related problems. Though, such a scheme limits the concurrency. We will talk about a two-phase locking method in the next subsection that gives sufficient concurrency. Though, let us first discuss multiple mode locks.


Related Discussions:- Types of locks

E-R Diagram, The H. I. Topi School of Business operates international busin...

The H. I. Topi School of Business operates international business programs in 10 locations throughout Europe. The school had its first class of graduates in 1965. The school keep

Define 1 nf normal form, 1 NF Normal Form The domain of attribute must...

1 NF Normal Form The domain of attribute must add only atomic (simple, indivisible) values First normal form (Minimal Form or 1NF) is a normal form need in database normalizat

Define forms based interfaces, Define Forms Based Interfaces? Forms-Bas...

Define Forms Based Interfaces? Forms-Based Interfaces - A forms-based interface display a form to each user. Forms are commonly designed and programmed for naive users and inte

Entity integrity constraint - relational constraints, It defines that no pr...

It defines that no primary key value can be null. This is as the primary key is used to recognize individual tuple in the relation. So we will not be able to recognize the records

Database, 3. (10 points) Assume that you have been presented with the follo...

3. (10 points) Assume that you have been presented with the following relation for the Baxter Aviation database: Charters (Pilot#, Pilot name, Aircraft ID#, #seats, Village, Fligh

What is 2nf, What is 2NF? A relation schema R is in 2NF if it is in 1NF...

What is 2NF? A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully functionally dependent on primary key.

Explain difference between volatile, Explain the difference between the thr...

Explain the difference between the three storage types - volatile, non volatile and stable.             Ans: Volatile storage: if storage media loses data while power goes off,

Assignments, i have assignments I don''t have time to finish because of wo...

i have assignments I don''t have time to finish because of work and other assignments, can you help with this? All are from the book Darabase design, application development and a

What do you mean by correlated subquery, What do you mean by Correlated sub...

What do you mean by Correlated subquery? Subqueries, or nested queries, are used to bring back a set of rows to be used by the parent query. Depending on how the subquery is writ

Create a database, Project: Microsoft Access You have been asked by the ...

Project: Microsoft Access You have been asked by the ABC Tanning Salon to create a database that can be used to track the salon's customers.  You are to create a table in Access

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd