One of the three basic methods to treat deadlock. The other two are deadlock avoidance and deadlock detection.

Deadlock prevention consists on imposing restrictions on the requests the processes may do in order to make it impossible for a deadlock situation to happen. Deadlock will be impossible if we never reach any of its four preconditions: mutual exclusion, hold and wait, non preemption and circular wait. Normally, mutual exclusion can't be avoided, because each instance of a resource can only be used by one process. However, the other three conditions can be avoided as follows:

Hold and wait: Either force processes to request all the resources at once (preallocation) or force processes to free all the resources they have allocated before asking for more. The first solution causes low resource usage, the second may cause process starvation.

Non preemption: If a request can't be satisfied because there aren't enough free resources, remove all the resources currently allocated by the process which made the request and put the process to sleep until both the resources it previously had and the ones requested are free. This solution may cause starvation.

Circular wait: Assign an ID number to each resource type. A process can't request a resource if it already has allocated resources with a bigger ID number. This solution doesn't cause starvation or low resource usage, but it's not very "programmer-friendly".