Friday, February 5, 2010

Exercise (Feb. 06, 2010)

Deadlocks

Case 1: Deadlocks on File Request

Example:


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

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

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

Case 2: Deadlocks in Database

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.

-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.

Case 3: Deadlocks in Dedicated Device Allocation

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.

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

-examples are printers, plotters or tape drives.

Case 4: Deadlocks in Multiple Device Allocation

Example:


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

Case 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.

Case 6: Deadlocks in a Network

Example:


-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.

Case 7: Deadlocks in Disk Sharing

Example:


-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.

No comments:

Post a Comment