Deadlock

Suppose that processes P0 and P1 are executing. Process P0 is accessing and holding the lock on the computer's printer, and process P1 is accessing and holding the lock on the disk. P0 will only release the printer if it gets access to the disk, and P1 will only release the disk if it gets access to the printer. This is an example of a deadlock.

A deadlock is a situation in which two or more processes or threads are waiting forever for the resources that other processes hold and refuse to release until they get their friends' resources.

Resources include memory frames, printers, CPUs, open files, tape drives, CD-ROMS, etc., and are usually limited in amount.

Sometimes there are several resources of the same type, like 2 printers, and it doesn't matter for a process which printer to use. Still, in many cases, there may be only one resource of a type (e.g., a single CPU.)