There are four necessary condition for happenning deadlock in system.
Mutual Exclusion Solution Spool Everything
Hold and wait Solution Request all the required resourses before start of the execution but remember it is not practical.
No-Preemption Solution Preempt the process to using resourses.
Circular Wait Solution Assign each resources a unique number and each process always request to resourses in increasing order of the number never go for backward but go for forward.