Tuesday, February 9, 2010

7 Cases in deadlocks

1. Deadlocks on file requests

Any other programs that require F1 or F2 are put on hold as long as this situation continues.

If jobs can request and hold files for duration of their execution, deadlock can occur.

Deadlock remains until a programs is withdrawn or forcibly removed and its file is released.

Example:




2. Deadlocks in databases

Deadlock can occur if 2 processes access & lock records in database.

3 different levels of locking :

entire database for duration of request

a subsection of the database

individual record until process is completed.

If don’t use locks, can lead to a race condition

Example:

1. P1 accesses R1 and locks it.

2. P2 accesses R2 and locks it.

3. P1 requests R2, which is locked by P2.

4. P2 requests R1, which is locked by P1.

3. Deadlocks in dedicated device allocation

Deadlock can occur when there is a limited number of dedicated devices.

E.g., printers, plotters or tape drives.

Example:

1. P1 requests tape drive 1 and gets it.

2. P2 requests tape drive 2 and gets it.

3. P1 requests tape drive 2 but is blocked.

4. P2 requests tape drive 1 but is blocked.

4. Deadlocks in multiple device allocation

Deadlocks can happen when several processes request, and hold on to, dedicated devices while other processes act in a similar manner.

Example:




5. Deadlocks in spooling

Most systems have transformed dedicated devices such as a printer into a sharable device by installing a high-speed device, a disk, between it and the CPU.

Disk accepts output from several users and acts as a temporary storage area for all output until printer is ready to accept it (spooling).

If printer needs all of a job's output before it will begin printing, but spooling system fills available disk space with only partially completed output, then a deadlock can occur.

6. Deadlocks in disk sharing

Disks are designed to be shared, so it’s not uncommon for 2 processes access different areas of same disk.

Without controls to regulate use of disk drive, competing processes could send conflicting commands and deadlock the system.

7. Deadlocks in a network

A network that’s congested (or filled large % of its I/O buffer space) can become deadlocked if it doesn’t have protocols to control flow of messages through network.

Example:



No comments:

Post a Comment