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

What are the two methods for dealing deadlock problem, What are the two met...

What are the two methods for dealing deadlock problem? The two procedures for dealing deadlock problem is deadlock detection and deadlock recovery.

Implementing a distributed database system, A distributed database is defin...

A distributed database is defined as "a collection of multiple logically interrelated database which are physically distributed over a computer network" (a) Give any three advan

Draw an e-r diagram and convert it to a relational schema, In an organizati...

In an organization several projects are undertaken. Each project can employ one or more employees. Each employee can work on one or more projects. Each project is undertaken on the

Wait-die scheme -deadlock prevention, Wait-die" scheme : The idea is based ...

Wait-die" scheme : The idea is based on non-preventive method. It is based on a simple rule:                                 If Ti requests a database resource that is held by T

What are the two aspect to the implementation of association, What are the ...

What are the two distinct aspects to the implementation of associations? i) It is required to define data declarations which will enable details of actual links to be stored. I

ERD, A student entity type has the following attributes,name..

A student entity type has the following attributes,name..

Explain i command in qbe, Explain I command in QBE ? I : It is the co...

Explain I command in QBE ? I : It is the command in QBE that is used to insert tuple (s) into the database

Lock, lock and types of lock

lock and types of lock

Differance between join and outer join, Differentiate between join and oute...

Differentiate between join and outer join? Outer joins return all rows from at least one of the tables or views mentioned within the FROM clause, as long as those rows get toge

Functional dependencies, CAR SALE (Car_id, Option_type, Option_listprice, S...

CAR SALE (Car_id, Option_type, Option_listprice, Sale_date, Option_discountedprice) This relation refers to options installed in cars (e.g., cruise control) that were sold at a de

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