A deadlock occurs when processes are waiting for resources held by other waiting processes, resulting in a circular wait. For deadlock to occur, four conditions must hold simultaneously: mutual exclusion, hold and wait, no preemption, and circular wait. A resource-allocation graph models processes and resources as vertices with request and assignment edges. A deadlock exists if the graph contains a cycle with only one instance of each resource type. Methods to handle deadlocks include prevention, avoidance, recovery after the fact, or ignoring the problem.