.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Eminent IT
Sandeep Singh

Home >> Interview Question >> Sql Server >> Post New Question Subscribe to Interview Questions

What is a deadlock and what is a live lock? How will you go about resolving deadlocks?

Posted By :Subhransu Sekhar Jena     Posted Date :October 31, 2014    Points :40   Category :Sql Server 
Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other's piece. Each process would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user's process.
A livelock is one, where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.
Check out SET DEADLOCK_PRIORITY and "Minimizing Deadlocks" in SQL Server books online. Also check out the article Q169960 from Microsoft knowledge base.

You can also find related Interview Question to What is a deadlock and what is a live lock? How will you go about resolving deadlocks?  below: 

List the Coffman's conditions that lead to a deadlock.

1. Mutual Exclusion: Only one process may use a critical resource at a time.

2. Hold & Wait: A process may be allocated some resources while waiting for others.

3. No Pre-emption: No resource can be forcible removed from a process holding it.

4. Circular Wait: A closed chain of processes exist such that each process holds at least one resource needed by another process in the chain. (More...)

What is a DEADLOCK?

It is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does (More...)

What is a "dead lock"?

A "Dead Lock" happens when two or more transaction is locked from a common resource. In this case each must have to wait for the other to unlock that resource. (More...)

What is "Shared Lock"?

Shared lock is also known as "S Lock" and is also called a Read Lock. it allows other transaction to read a record. (More...)

What is "Exclusive Lock"?

It is otherwise called as "White Lock". It prevents another transaction from reading a record until it is unlocked. (More...)

What is difference between lock vs static locks?

static lock is applicable to static methods and variables.

What is the purpose of lock statement?

To denote critical section while in a multi-threaded application (More...)

What is the difference between lock and Mutex?

One of the differences between Mutex and lock is that Mutex utilizes a kernel-level construct, so synchronization will always require at least a user space-kernel space transition.
lock - that is really a shortcut to the Monitor class, on the other hand tries to avoid allocating kernel resources and transitioning to kernel code (and is thus leaner & faster - if one has to find a WinAPI construct that it resembles, it would be CriticalSection).

Mutex is a cross process and there will be a classic example of not running more than one instance of an application.
while, Lock is a simplest way to protect section of your code and it is appdomain specific , you can replace lock with Moniters if you want more controlled synchronization.

A lock is specific to the AppDomain, while Mutex to the Operating System allowing you to perform cross-process locking and synchronization. (More...)

What are the Lock Types in SQL server?

Shared lock
Update lock
Exclusive lock (More...)

Will Silverlight support live streaming events as well as downloading media?

Yes. Silverlight together with Windows Media Services enable live streaming experiences.

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend