Deadlock occurs when two or more competing processes are each waiting for resources held by the other, resulting in all processes waiting indefinitely. There are four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Techniques to prevent deadlock include attacking each condition: allowing some resources to be shared, requiring processes request all resources at start, allowing preemption of resources, and imposing a global numbering on resource requests.