What is deadlock? Explain necessary conditions to occur the deadlock. code example

Example 1: what is deadlock

Deadlock is a situation where a set of processes 
are blocked because each process is holding a resource 
and waiting for another resource acquired by some other
process.Process 1 is holding Resource 1 and waiting for
resource 2 which is acquired by process 2, and process 2
is waiting for resource 1.

Example 2: what are the deadlock conditions

Deadlock in OS is a situation where two or more processes are blocked. Conditions for Deadlock- Mutual Exclusion, Hold and Wait, No preemption, Circular wait. These 4 conditions must hold simultaneously for the occurrence of deadlock.

Tags:

Misc Example