"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

January 22, 2010

SQL Server 2008 R2 Feature - Data-tier applications

Downloaded and Installed SQL 2008 R2 Bits. Link
Data Tier Application - data-tier application (DAC) defines the SQL Server Database Engine schemas and objects that are required to support an application. Link. All the elements of Database - Schema, Procs, Triggers, Views can be extracted into a Data Tier App Project. This is same as reverse engineer feature we have in VSDB 2008 where we can extract all objects from a database in a database project.

DAC is available from SQL 2008 R2 onwards. VSDB project supports from SQL 2005, 2008, R2 versions.
Created a Test Database and created few tables and Procs
--STEP 1
CREATE TABLE TESTTable1
( Id INT Identity(1,1),
Name VARCHAR(50))

INSERT INTO TESTTable1(Name)
SELECT 'Test'

CREATE PROC TestProc
(@Id Int)
AS
BEGIN
 SELECT * FROM TESTTable1 (NOLOCK) WHERE Id = @Id
END

--STEP 2
Extracting Data Tier Application. Right click on Database->Tasks->Extract Data Tier Application


After this provide properties and save the Package


Created a Datatier App in VSTS 2010


Import the Created Data Tier Application from the package


After Successful Import, You Can view the tables, procedures created in it.


Now if you want to deploy this in a database. Choose Project->Properties->Under Deploy Options->Specify the connection to directly deploy it. I am able to successfully build it. On trying to deploy I got the error Invalid object name 'msdb.dbo.sysdac_instances'. I am trying to deploy of SQL 2008 Instance. It need to be R2/CTP3 to support Data Tier Deployment.

More Reads

Microsoft SQL Server Management: Developing Managed Data-Tier Applications


Happy Learning!!!

Troubleshooting blocking

Blocking Definiton - Attempting to acquire a lock that conflicts with a lock held by another connection.
Deadlock Definition - A deadlock is a circular blocking chain, where two or more threads are each blocked by the other so that no one can proceed (Source)

Demo Blocking
Create simple tables for test purpose
--STEP 1

CREATE TABLE TESTTable
(Id Int Identity(1,1),
Name VARCHAR(50))

--STEP 2
--Populate Data
DECLARE @i int
SET @i = 0
WHILE 1 = 1
BEGIN
INSERT INTO TESTTable(Name)
SELECT CONVERT(VARCHAR(20),@i)+'Test'
SET @i = @i+1
IF @i > 10000
BREAK;
END

--STEP 3
BEGIN TRAN
Update TESTTable
SET Name = '1Test1'
WHERE Name = '1Test'

Open another new session (Not a gr8 query a little example to block it, Transaction is open in both the cases)
STEP 1
BEGIN TRAN
Update TESTTable
SET Name = '1Test1'
WHERE Name = '1Test'

Open another session to detect blocking

STEP 1
Run the below query to check for blocking. This would show current blocking. More details at statement level run query provided in next step.
SELECT * FROM sys.sysprocesses WHERE blocked <> 0
STEP 2
One more blocked query script. This would show blocking and waiting statement and details.
Source - http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/trans/sql05vb044.mspx?mfr=true
 
This query would show
STEP 3

Setup blocked process report as provided in link
Monitoring for Blocked Processes On SQL 2005 - Extended Version
This is very clearly explained in provided link. 
When To Use Blocked Processes Reports
Zeroing in on blocking on seemingly unrelated tables
CodePlex - SQL Server Blocked Process Monitor
Troubleshooting Blocking 101 on SQL Server


Happy learning...

January 12, 2010

SSIS Error - [Execute SQL Task] Error: An error occurred while assigning a value to variable "xxxx"

I spent 2 hours for this. DataType was bigint and I was unable to assign output value. Below URL was useful to fix it http://blogs.msdn.com/mattm/archive/2007/04/18/why-can-t-i-store-my-bigint-result-in-an-int64-variable.aspx. Finally I have to type change base datatype to int and SSIS variable is INT32. This is on VS2005, SSIS 9.0

Second Learning is Eventlogging. Since, I am working on SSIS 2005 I tried for a VB code EventLog.Source Property

SQL Server 2005 Integration Services (SSIS): Custom Logging Using Event Handlers

SSRS Tip - Repeat Header / Keep Header Visible in Tables in RS 2008

More Reads
SSIS Balanced Data Distributor – Comparison

January 10, 2010

SQL Perf Tuning - Performance Counters and Values

I have come across lot of blogs with queries to find Top IO, CPU queries.
  • Learn to differentiate IO Issue, CPU Issue, Network Issue
  • IO Issue - Excessive IO can be due to a SCAN on a big table. There are ways to convert SCAN to SEEK. In a OLTP system query are expected to be highly selective, fetch few records
  • CPU Issue - During processing we might have temp tables, Sort a Temp tables. Sort Operator is usually CPU intensive. Wait Stats sys.dm_os_wait_stats DMV provides more info. Please check Joe Sack wait stats link mentioned below
  • Disk Issue - PhysicalDisk/LogicalDisk counter in below bookmarked excel and values defined for it for interpreting Disk Issues
  • Network Latency - Network Interface counter in below excel provides values for counters and interpreting them
List of Counters and Optimal values for them


From Perfmon counters interpret from values of perfmon counters. Attached XL is very very good.
Without writing any query how do we find expensive queries
  • Activity monitor check recently expensive queries
  • Goto Particular Database that you want to check. List Reports for Reports->Standard Reports->Top Transactions by Age, Locks
  • Check Parallelism Enabled/Not Link
Saleem has written a good article on step-by-step Analysis for query troubleshooting. Link is


Happy Learning!!!

Using DMVs to find Execution Plan of Currently Running Queries

We would check on currently running queries how do we find execution plan of the queries. For demo purpose would create some tables and try some long running queries

Compiled Plan 
  • Compiled plan is product of query optimization
  • Stored in object store or sql store
  • Compiled plan would specify which table and indexes to access
  • Multiple concurrently executing queries can share same compiled plan
  • Can be shared between multiple sessions and users
 Executable Plan
  • Adding Parameter, variable to compiled plan
  • Information specific to one particular execution
  • Runtime objects created when compiled plan is executed
Plan Handle
  • Cached compiled plan retrieved using plan handle
  • sys.dm_exec_cached_plans contains plan handle for every compiled plan
  • Plan handle is hash value sql server derives from compiled plan
SQLhandle
  • Actual text stored in SQL Manager Cache
  • Transact SQL text cached in sql manager cache retrieved using sql_handle
SQL Handle: Plan handle - 1:N

Source: MSDN Blogs. I hope I learnt things right. Sql_Handle and Plan_Handle Explained

Session 1
Step 1
USE TEMPDB
CREATE TABLE DBO.TESTTable
(
Id INT Identity(10,10),
Name VARCHAR(20)
)
 
STEP 2
--Insert some records with below command. I am trying on SQL 2008 R2
INSERT INTO DBO.TESTTable(Name)
Values ('Testvalue')
GO 50

--STEP 3 --Lets try running below statement, This is a infinite loop
While 1 =1
BEGIN
      SELECT Top 1 Name FROM DBO.TESTTable
END
 
Open another query session and lets try to get details on this query from DMVs
Session 2
STEP 1
USE TEMPDB
--View the query and Plan of currently running queries
SELECT *
FROM sys.dm_exec_requests
CROSS APPLY sys.dm_exec_sql_text(plan_handle)
CROSS APPLY sys.dm_exec_query_plan(plan_handle)
 
Output would be like below
Take the plan handle value displayed in the right and run below query with plan handle value
 
STEP 2
SELECT *
FROM sys.dm_exec_sql_text(0x060002003A882A10B820FF04000000000000000000000000)
--Plan Handle

You will see the running query details as below

You will see the running query details as below
STEP3
To view the execution plan of the query run the below query with the plan handle value
SELECT *
FROM sys.dm_exec_query_plan(0x0600020056218802B880F104000000000000000000000000)

This would show us the XML show plan as below
Take the plan and check further. More details on execution plan you can find on execution plan tagged posts.


More Reads
GOTCHA: SQL Server changes query plan without changing plan_handle


Happy Reading!!

January 09, 2010

BCP Basics

I didn’t know bcp command. I had to restore few tables. I learnt it anyways.

Bcp utility copies data between an instance of SQL Server and a data file

To bcp out data, Get data from a Table
BCP Syntax - bcp DB.SCHEMA.TableName OUT FileLocation -SServerName -T –c

T - trusted connection
c - Performs the bulk copy operation using a character data type. This option does not prompt for each field

Use TempDB
--STEP 1
--CREATE A TABLE
CREATE TABLE DBO.TEST
(
  Id INT Identity(1,1),
  Name VARCHAR(20)
)

--STEP 2
INSERT INTO DBO.TEST (Name)
Values('Data')
Go 50

--STEP 3
--From Cmd Prompt Run below query
bcp tempdb.DBO.TEST out D:\bcp_TEST.dat -T -c

To bcp in data (Restore Data to a table from a data file)
BCP Syntax - bcp DB.SCHEMA.TableName in FileLocation -SServerName -T –c

--STEP 4
CREATE TABLE DBO.TEST12
(
  Id INT Identity(1,1),
  Name VARCHAR(20)
)

--STEP 5
--To bcp in data, run from cmd prompt
bcp Tempdb.dbo.TEST12 in D:\bcp_TEST.dat -T -c

--STEP 6
SELECT * FROM TEST12

Reference - bcp Utility, BCP Basics, The ABCs of Bcp

January 01, 2010

.NET Basics, OOPS, C++, Biztalk, Algorithms, Java Basics Notes and UML

I think its time for me to ramp up with .NET as well. I am revising my .NET notes I got few years
back.

OOPS
  • Inheritance - Code reuse, Better Maintenance
  • Polymorphism - Different Phases (Operator Overloading, Operator Overriding)
  • Encapsulation - Ability to hide internals of an object from its users and provide interface to only those members that you want client to be able to directly manipulate
  • Data Encapsulation or Information Hiding - Concealing the implementation details of a data object from the outside world
  • Data Abstraction is seperation between specification of a data object and its implementation
  • OOPS basics notes Link
  • Abstract Class cannot be instantiated but inherited. Normally base class is declared with abstract keyword and derived class should extend abstract class and implement relevant methods. C# does not support multiple inheritance.
  • Interface can be implemented but cannot be instantiated. Interface can be implemented by other classes.
  • Virtual Class: There is no virtual class. It could be lingo to abstract class.
  • Pure Virtual Function: Virtual function initialized to zero
  • Union is a structure that reserves storage for the largest of its data members so that only one of its data members can be stored at any time. Useful in Applications where it is known that only one of many possible data items.
  • Typing - Strong Typing helps detect mismatched assignment statements.
  • C++ Program Data Access
    • Public  - Accessible anywhere in the program
    • Private - Class members, functions, friend function. Accessed from within class or by a function or a class that is declared to be friend
    • Protected - Within its class or subclass or friend. Data member can only be accessed from within its class or from its subclasses or by a friend
  • [Refresher] - Inside Microsoft Source Code – What is .NET Framework ?
Advantages of managed code
  • Platform independant
  • JIT (Just in time Compilation)  - Dynamically Compiles Intermediate language (MSIL) code into native code that is optimized for execution for target operating system. Intermediate code compiled into CPU dependant executable code.
Features of CLR
  • Managed Code - Code which runs under CLR. Assemblies, MSIL
  • Memory management
  • Automatic Garbage Collection
  • Security
Value Type - An instance of value type represents actual data. Stored in Stack. Value Types are Simple Data Types, Enums, Structs.

Reference Type - Instance of reference type represents pointer or reference to data. Stored in Heap. Classes, Interfaces, Arrays and Delegates are Reference Types.
Assembly - File automated on successful compilation of every .NET Application. Can be Either a DLL or Executable Code. Assembly contains Intermediate Language Code.
Boxing - Converting primitive type to reference type
UnBoxing - Reference Type to value type
int a = 10; //Value Type
object x = a; //Boxing
int z = (int)x; //Unboxing
  • CLS - Common Lanuage Specification
  • CLR - Part of Framework
Class Library
  • Feature of .NET Framework
  • Precompiled libraries
  • Inbuilt methods in libraries can be used in our program
JIT - While execution runs code only for current input value
e.g if(a==10)
      {
   
      }
      else
      {

      }
If value of a is 10 then only that part will be choosen.
  • ILDASM - Intermediate Language Dis-Assembler
  • ILASM - Intermediate Language Assembler
  • MSIL - Microsoft Intermediate Language
More Reads
  • Mutable Objects: When you have a reference to an instance of an object, the contents of that instance can be altered
  • Immutable Objects: When you have a reference to an instance of an object, the contents of that instance cannot be altered
Basics of JSON from Database Basics class from Coursera 

What is JSON ?
  • JSON (Java Script Object Notation)
  • JSON is used for data interchange
  • Suitable to semi structured data
  • Parsers available for JSON in different programming languages
  • Based on Name/Value Pairs, Supports Arrays
  • Self Describing Data, Schema Elements within data
JSON VS XML 
  • JSON is less complex than XML
  • DTD (Document Type Descriptions, Schema) for Schema Compliance
  • JSON Schema Available to specify structure
  • XPATH, XQUERY available for XML querying, JSON Path in progress
SOA - Approach to integrate diverse systems. Service-oriented architecture (SOA) is an approach to loosely coupled, protocol independent, standards-based distributed computing where software resources available on the network are considered as Services.

SOA is an approach to architecture. Cloud computing is a way of deploying aspects of architecture, including SOA.Infrastructure as a Service(Managed in Cloud), Platform as a Service, Software as a Service(Application available as service)
Enterprise Service Bus (ESB) is widely used in the context of implementing an infrastructure for enabling a service-oriented architecture (SOA). Microsoft ESB Guidance uses Microsoft BizTalk Product (Messaging Architecture).
Enterprise Application - Enterprise application is a business application. They are complex, scalable, distributed, component-based, and mission-critical. Deployed across Internet/Intranet.
Data center - server farm or server cluster, also called a data center, is a collection of computer servers usually maintained by an enterprise to accomplish server needs far beyond the capability of one machine
Further Reads
How does a web service actually work ?

I got this MSDN link extremely useful. Anatomy of an XML Web Service Lifetime
SOA, where will BizTalk Server fit in the technology stack (from performance perspective)?
Web Service Architecture
SOAP is a simple XML-based protocol to let applications exchange information over HTTP
Biztalk Notes

Biztalk is a messaging based integration tool. It consists of several different pieces including Business Processes (Orchestrations), BAM, Rules Engines.
BizTalk Server 2006 can process two different types of schemas: XML schemas and flat-file schemas. Both types of schemas use XML Schema definition language (XSD) to define the structure of the message.
XML schema: An XML schema defines the structure of XML messages. Messages are validated against associated schema.
Flat-file schema: Uses flat-file format. Flat files can be either delimited or positional.
What is the difference between a Distinguished field and a Promoted Property?

Distinguished fields are light weight and can only be used inside an Orchestration.

Promoted Properties are defined inside a property schema, are tracking in SQL, can be tracked in HAT, and can be used for content based routing.
What is direct binding?
  • Direct binding has three types: direct to message box, self correlating, and partner ports.
  • Used to route message between the message box and Orchestrations without using bindings or from one Orchestration to another Orchestration.
Biztalk Web Service Support
  • Consuming a Web service From Biztalk
  • Publishing an orchestration as a Web service
BizTalk: Interview questions and principles
BizTalk: Questions for interview without answers
WCF: Questions for studying and interview

Interview Basics
How does http work
  • Hypertext Transfer Protocol
  • HTTP is a connectionless text based protocol
  • The web browser connects to the web server and sends an HTTP request (via the protocol stack) for the desired web page
  • The web server receives the request and checks for the desired page. If the page exists, the web server sends it. If the server cannot find the requested page, it will send an HTTP 404 error message
  • The web browser receives the page back and the connection is closed
  • The browser then parses through the page and looks for page elements (Ex-Images) it needs to complete the web page. For each element needed, the browser makes additional connections and HTTP requests to the server for each element.
Learnt/Reproduced from URL - How Does the Internet Work?
TCP and HTTP, fighting each other to bring you the web

What is difference between threads and process
The major difference between threads and processes is
1. A process can contain more than one thread.
2. A process is considered as “heavyweight” while a thread is deemed as “lightweight”.
3. Modifying a main thread may affect subsequent threads while changes on a parent process will not necessarily affect child processes.
4. Threads within a process communicate directly while processes do not communicate so easily.
Reference Link
  • Threads share the address space of the process that created it; processes have their own address.
  • Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process.
  • Threads can directly communicate with other threads of its process; processes must use interprocess communication to communicate with sibling processes.
  • Threads have almost no overhead; processes have considerable overhead.
  • New threads are easily created; new processes require duplication of the parent process.
  • Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. 
  • Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process; changes to the parent process does not affect child processes. Link

Windows Architecture - Threads Vs Process (Good Notes)
  • A thread lives in a process, and executes the instructions of the program
  • To be more specific, a process is a running instance of an application, together with a set of resources that are allocated to the running application.
  • In short, threads, not processes, execute program code. Every process must have at least one thread
  • The purpose of threads, of course, is to allow a process to maintain more than one line of execution, that is, to do more than one thing at a time
  • In a single-processor environment, the CPU must provide time slices to each thread that is currently running on the system
  • In a multiprocessor environment (a computer with more than one CPU), Windows NT (but not Windows 9x) can assign different threads to different processors, providing true multiprocessing
What is Recursion
Key to a recursive procedure is that with each recursive call, the problem domain must be reduced in such a way that eventually the base case is arrived at.

Without Recursion
#include<stdio.h>
void main()
{
    int result;
    clrscr();
    printf("Hello World\n");
    result = fact(5);
    printf("%d",result);
}
int fact(int i)
{
    int j=1;
    int result=1;
    for (j=1;j<i;j++)
   {
        result= result*j;
   }
    return result;
}

With Recursion
unsigned int factorial(unsigned int n)
{
     if (n <= 1)
    {
         return 1;
    }
    else
   {
        return n * factorial(n-1);
   }
}

Fibonacci Series

With Recursion
int fib(int n)
{
    int x, y;
    if(n<=1) return n;
    x = fib(n-1);
    y = fib(n-2);
    return (x+y);
}

Without Recursion
int fib(int n)
{
    a = 0; b = 1;
    for(i=2; i <=n; i++)
    {
        c = a+b;
        a = b;
        b = c;
    }
    return c;
}
What is difference between Array and Linked List
  • Elements can be inserted into linked lists indefinitely
  • An array from which many elements are removed may become wastefully empty or need to be made smaller.
  • Arrays allow random access
  • Linked lists allow only sequential access to elements
Properties of Array
  • Individual data items in the array are called elements
  • All elements must be of same datatype
  • All elements are stored contiguosly in memory
  • Name of array represents address of first element of the array
Disadvantages of Array
  • Fixed Lengh
  • Wasted Storage
  • Resizing affects performance
Advantages of Array
  • Contiguous Storage
  • Random Access
  • Fixed length
  • Easy to Implement
Passing Array Elements to a Function
a. by value - pasing values of array elements to the function
b. by reference - passing address of array elements to the function

What is difference between Stack and Array
Stack
  • Ordered collection of items
  • Insertion and Deletion at one end called top of stack
  • Stack - Last In First Out
Application of Stacks: Recursion, Conversion of expressions, passing parameters, Text Editors
Queue:
  • FIFO, Linear Data Structure
  • Insertion - Rear, Deletion - Front
  • Basically a line with some entities kept for service
Application of Queues: Pushing printing jobs to printer, multiprogramming
Dequeue
  • Double Ended Queue
  • Used in System Programming
  • Element can be added and deleted at both the ends
Priority Queue
  • Highest Priority removed
  • Increasing Priority - Lowest element removed
  • Decreasing Priority - Highest element removed
Critical section - Critical section is a piece of code that accesses a shared resource (data structure or device) that must not be concurrently accessed by more than one thread of execution. This brute-force approach can be improved upon by using semaphores. To enter a critical section, a thread must obtain a semaphore, which it releases on leaving the section.
Trees - Abstract data structures consisting of nodes and pointers

Complete Binary Tree - 0 or 2 children. Filled at level n or n-1

Application of Trees - Searching, Sorting, Efficient Network Representation

Context switch - enables multiple processes to share a single CPU resource. The context switch is an essential feature of a multitasking operating system. Multitasking, Interrupt Handling.
Binary search tree (BST) is a node-based binary tree data structure which has the following properties.
  • The left subtree of a node contains only nodes with keys less than the node's key.
  • The right subtree of a node contains only nodes with keys greater than the node's key.
  • Both the left and right subtrees must also be binary search trees
Refresh Basics - Sorting Algorithms

Entity Framework Q&A

Behavior Driven Development using MVVM pattern and GreenPepper tests

MVC - Basics

From Link


Refactoring
  • Rewriting, reworking, and re-architecting code is collectively known as refactoring
  • Helps remove Code Duplication, Include features that would improve code/algorithm performance
  • Helps Incorporate Code-Reviews comments, Validate Coding Standards and guidelines followed
Databases

Read Quote of Alex Yakunin's answer to Database Systems: How does a relational DBMS internally store its data? on Quora

What is ORM 
  • ORM stands for Object-Relational Mapper
  • Mapping Domain model to DB Schema
  • Good ORM will let you develop without knowing DB Schema
  • Source - Link 
Different ORM Tools Comparision 

  • ADO.NET Entity Framework,LINQ to SQL,BLToolkit,DataObjects.Net,LinqConnect,NHibernate,OpenAccess,Subsonic
  • Source - ORMeter  
Interfaces - Contains one or more methods, properties but none of them are implemented in the interface itself. Methods in the interface are abstract, they do not include implementation code.
UML - Unified Modelling Language
Use Case Diagram - Shows Actors, Use Cases and their relationships
Class Diagram - Shows classes and their relationships with each other
Bicycle Class
  • Attributes - frame size, wheel size, gears, material
  • Operations - shift, move, repair
Polygon Class
  • Attributes - vertices, border color, fill color
  • Operations - draw, erase, move
Animal Class
  • Attributes - legs, hasfeathers, nightvision, canswim, gender
  • Operations - fly, run, move, eat, swim
More reads - Link1, Link2, Link3
All time favourite 'C & C++'

Malloc - It returns an address of type void * that points to first byte of this space. If Error is occured or no more space is available then address Zero(NULL) is returned

Calloc - Takes two arguments: number representing how many elements are to be allocated, argument specifying size of each element. All of allocated space is automatically initialized to zero

New Operator in C++ - malloc( ) always returns a pointer of type void *, the new ( ) operator returns a pointer of the type of object being allocated.

Copy constructor - constructor to handle the creation and initialization of a class instance via an existing instance is called the copy constructor
#include<iostream.h>
class date
{
int day;
int month;
int year;
public:
date(int d=0,int m=0, int y=0)
{
day = d;
month = m;
year = y;
}
//copy constructor
date(date &d)
{
day = d.day;
month = d.month;
year = d.year;
}
//overloaded assignment operator
date operator =(date d)
{
day = d.day;
month = d.month;
year = d.year;
return d;
}
void display()
{
cout<<day<<"/"<<month<<"/"<<year;
}
};
int main()
{
date d1(21,10,1980);
date d2 = d1;
date d3;
d3=d2;
d3.display();
getchar();
return 1;
}

Refreshing my basics - Java Interfaces, Lists, Arrays

Interfaces
  • Declared using the interface keyword
  • Defines only abstract methods and constants
  • Interfaces cannot be instantiated
  • class that implements an interface must implement all of the methods in Interface
Advantages - Simulate multiple inheritance
Abstract Classes
  • Abstract class can define both abstract and non-abstract methods
  • You can implement multiple interfaces at the same time, but only extend one class
Do's with Abstract Class 
  • You can call a static method on an abstract class
  • You can define both abstract and non-abstract methods in abstract class
Dont's with abstract keyword
  • Static, private, and final methods cannot be abstract, since these types of methods cannot be overridden by a subclass.
  • Similarly, a final class cannot contain any abstract methods
Error Types (Logic Errors, Syntax Errors, Runtime Errors) - Link1, Link2
Basics BTree, Binary Tree
  • Binary tree - A tree where each node has at most two children.
  • Binary search tree - A binary tree that exhibits the following property: for any node n, every descendant node's value in the left subtree of n is less than the value of n, and every descendant node's value in the right subtree is greater than the value of n
Posting below FAQ collection I prepared couple of years back

OS Related Questions

What is deadlock and what are the necessary conditions for it to occur?
Deadlock is when all threads in a set are waiting for something that only one of the other threads in the set can cause, so none can make progress. The necessary conditions for deadlock are: mutual exclusion of resources, no preemption of resources, incremental resource acquisition, and a circular wait pattern.

How does ordered acquisition of resource types avoid deadlock? Specifically relate your answer to the necessary conditions for deadlock from above.
It eliminates the possibility of a circular waiting pattern.

What is the difference between deadlock and livelock?
In deadlock, no thread is making progress at all, since they are all waiting. In livelock, threads are making progress, but the progress isn't useful since they just keep repeating the same action(s).

What is the difference between livelock and starvation?
In livelock, threads get chosen for execution, but with starvation they are never given a chance to execute.

Difference between Quick Sort and Merge Sort
  • In Merge Sort,the splitting is trivial (simply taking two halves) and the joining is hard (merging the two sorted files).
  • Merge Sort is not an Inplace Algorithm
  • In Quick Sort,the splitting is hard (Partitioning) and the joining is trivial (the two halves and the pivot automatically form a sorted array).
  • Quick Sort is an Inplace Sort Algorithm.(i.e., it doesn't require additional temporary space to store elements as they sort,they use the space originally occupied by the elements).  More Reads Link, Sorting Algorithms
More Reads
Windows Architecture Reads
Java Notes
Algorithms in C#


Happy reading!!!