Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask DBMS Expert


Home >> DBMS

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.

DBMS, Programming

  • Category:- DBMS
  • Reference No.:- M9527787

Have any Question?


Related Questions in DBMS

Question 1 a- consider that you are asked to design an

Question: 1. (a)- Consider that you are asked to design an entity relationship diagram based on the below scenario: A university consists of a number of departments (id, d_name) and each department offers some courses. A ...

Assignmenta restaurant is designing a database to keep

Assignment A restaurant is designing a database to keep track of customer services. A customer is defined as a customer ID, name, address and a telephone number. Customers are served by employees. Each employee is define ...

Need an expert in the fields of system design to handle

Need an expert in the fields of system design to handle this project This is a system analysis and design project, not a research project. Refer to the list of deliverables in the instructions in the assignment to make s ...

Relational database design a given the following business

Relational Database Design A) Given the following business rules, identify entity types, attributes (at least two attributes for each entity, including the primary key) and relationships, and then draw an Entity-Relation ...

Analytic reportpurpose the purpose of this task is to

Analytic Report: Purpose: The purpose of this task is to provide students with practical experience in working in teams to write a Data Analytical report to provide useful insights, pattern and trends in the chosen/given ...

Question we can sort a given set of n numbers by first

Question : We can sort a given set of n numbers by first building a binary search tree containing these numbers (using TREE-INSERT repeatedly to insert the numbers one by one) and then printing the numbers by an inorder ...

You are responsible for keeping track of meal expenses for

You are responsible for keeping track of meal expenses for ten employees while at a business lunch to which your employer has invited you to attend. Write an algorithm that inputs the lunch costs for each the ten employe ...

Question 1 what isdata-manipulation language dml there are

Question: 1. What isData-Manipulation Language (DML)? There are four types of access in DML, explain each one. 2. Assume we have a Library Database consists of the following relations: author(author_id, first_name, last_ ...

Case study problem 1 the case study company has experienced

Case Study: Problem 1 The case study company has experienced rapid growth in both the size of its client base and also in the services provided to clients. Unfortunately, the growth in data management policies, procedure ...

Question 1 describe 1nf 2nf 3nf2 explain why 4nf is a

Question: 1: Describe 1NF, 2NF, 3NF. 2: Explain why 4NF is a normal form more desirable than BCNF. The response must be typed, single spaced, must be in times new roman font (size 12) and must follow the APA format.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As