Wednesday, December 22, 2010

Deadlocks - (Operating System)

DEADLOCKS

            Computer systems are full of resources that can only be used by one process at a time. Common examples include printer, tape drives, and slots in the system’s internal tables. Having two processes simultaneously writing to the printer leads to gibberish. Having two processes using the same file system table slot will invariably lead to a corrupted file system.


For many applications, a process needs exclusive access to not one resource, but several. Suppose, for example, two processes each want to record a scanned document on a CD. Process A requests permission to use the scanner and is granted it.  Process B is programmed differently and the request CD recorder first and is also granted it. Now A asks the CD recorder, but request is denied until B releases it. Unfortunately, instead of releasing for CD recorder B asks for the scanner. At this point both processes are blocked and will remain so forever. This situation called a deadlock.

 
            Deadlock can also occur across machines. For example, many offices have local area network with many computer connected to it. Often devices such as scanner, CD recorders, printer and tape drives are connected to the network as shared resources, available to any user on the machine. If these devices can be reserve remotely, the same kind of deadlocks can occur as described above. More complicated situation can cause deadlock involving three, four or more devices and users.