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 is entity in dbms, What is entity in DBMS? Entity: A DBMS entity i...

What is entity in DBMS? Entity: A DBMS entity is either a thing in the modelled world or a drawing element in an ERD.

Relational database, Consider the following relational database: STUDENT (n...

Consider the following relational database: STUDENT (name, student#, class, major) COURSE (course name, course#, credit hours, department) SECTION (section identifier, course#, sem

Define shadow paging, Define shadow paging. An alternative to log-based...

Define shadow paging. An alternative to log-based crash recovery method is shadow paging. This technique requires fewer disk accesses than do the log-based methods.

Lack of standards and experience, Lack of standards and experience: The la...

Lack of standards and experience: The lack of standards has considerably limited the potential of distributed DBMSs. As well, there are no tools or methodologies to help users cha

Approach to implement traffic data management, There are many simple and co...

There are many simple and complex approaches to implement. These reports are based on some views or certain query. The following number of reports can be built. 1. The averag

Serialisable schedules, Serialisable Schedules: If the processes of two tra...

Serialisable Schedules: If the processes of two transactions conflict with each other, how to verify that no concurrency related problems have happened? For this, serialisability t

Define catalog and meta data, Define Catalog and meta data ? A catalog ...

Define Catalog and meta data ? A catalog is a compilation of records elaborating the contents of a particular collection or group of collections. Metadata (Meta data, or someti

What is called block-level striping, What is called block-level striping? ...

What is called block-level striping? Block level striping stripes blocks across many disks. It treats the array of disks as a large disk, and provides blocks logical numbers

Attributes, Attributes and its types explain?

Attributes and its types explain?

Example of primary key, Suppose that in an organisation, an employee may do...

Suppose that in an organisation, an employee may do different roles in dissimilar projects. Say, RAM is doing coding in one project and doing designing in another. Suppose that the

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