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

Write a qbe query to display names of cs department, Consider a table stude...

Consider a table student (std_id, std_name, date_of_birth, percent_marks, dept_name). Write a QBE query to display names of Computer Science department students who have scored mo

Managing database, 10A.53 Code an Oracle Database trigger to enforce the ...

10A.53 Code an Oracle Database trigger to enforce the constraint that an employee can never change his or her department. 10A.54 Code an Oracle Database trigger to allow the

Create a database schema, Consider a database schema consisting of four rel...

Consider a database schema consisting of four relations, whose schemas are: Product (maker, model, type) PC (model, speed, ram, hd, price) Laptop (model, speed, ram, hd, s

Illustrate different types of locks in sql server, Illustrate different typ...

Illustrate different types of Locks in SQL Server. There are three kinds of locks in SQL Server i.) Shared locks - These are used for operations which don't allow any update

Explain how you can define an object model of a system, Explain how you can...

Explain how you can define an object model of a system. A list of terms that shall be used by end users to describe state and behaviour of objects in system.   Different use

Er diagram, Design a generalization–specialization hierarchy for a motor-ve...

Design a generalization–specialization hierarchy for a motor-vehicle sales company. The company sells motorcycles, passenger cars, vans, and buses. Justify your placement of attrib

What is indexed sequential file organization, What is indexed sequential fi...

What is indexed sequential file organization? What are the applications of this organization?  Ans: An index file can be employed to effectively overcome the problem of storing

Can a domain, Can a domain, assigned to a data element be changed? Yes....

Can a domain, assigned to a data element be changed? Yes.  We can do so by just overwriting the entry in the field domain.

Write short notes on relational model, Write short notes on relational mode...

Write short notes on relational model   The  relational  model  uses a  collection of  tables  to show  both data  and the relationships between those  data.  The relational mo

Dbms, statical data

statical data

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