Deadlock Occurs when two or more separate processes compete for resources held by one another.
For example take two process P1,P2.
and two resourses R1,R2,R3.
P1 is using R1,R2 and P2 is using R1,R3 and
P1 is need of R3 to complete the process and
P2 is need of R2 to complete. So P1 ll compete to take R3 and P2 ll compete take R2.
But P1 ll leave R2 only on completion of it process and P2 ll leave R3 on completion of its process.
So there s lock of resources between P1 and P3.
Hence this is deadlock.
To avoid deadlock there are many algorithms