chapter 10 deadlock - virginia tech · 2002. 10. 31. · three solutions to deadlock … #2:...
TRANSCRIPT
![Page 1: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/1.jpg)
Chapter 10Deadlock
![Page 2: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/2.jpg)
What is Deadlock?� �������������������� �������������������������������������
������������������
� ������������������� ��������
� ��� ��������������������
� ��������� ������������� �������������������������
�������������������������������������!
� ��������������"�������#������
� ��������������������������� ��������������������������
� ���������� ��������������������
� �����������������������������������������������������
�������
![Page 3: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/3.jpg)
Deadlock Illustration
A set of processes is in a DEADLOCK state when every process is waiting for an event initiated by another
process in the set
Process A
Request X
Request Y
Release X
Release Y
Process B
Request Y
Request X
Release Y
Release X
![Page 4: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/4.jpg)
Deadlock Illustration
� $���%�����&����������'
� (���%�����&����������)
� $���%�����)�� �������
� (���%�����'�� �������
����*+�� ����������,
' )
$
(
![Page 5: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/5.jpg)
����������
� -�����������!�.�/����������
� #���� ���!�������������������
� �����������#���� ������������ 0���
� �������������������������������� -����
![Page 6: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/6.jpg)
�����������1
� 2 ��������������
� 3��������������� ��� ������������� � ��������
��������
����������4��������������������������� -5������6778����
������������ ����� -5������������������������
![Page 7: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/7.jpg)
Three Solutions to Deadlock
#1: Mr./Ms. Conservative (Prevention)
time
Job waitsfor all resources
Job starts Job finishes
R2R1 WAIT
“We had better not allocate if it could ever cause deadlock”
| R1 in use |
| R2 in use |
-������������ ���������� � ��������������9������������������
![Page 8: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/8.jpg)
Three Solutions to Deadlock …
#2: Mr./Ms. Prudent (Avoidance)
time
Job starts Job firstneeds R1
Job finishes
R2R1
Job firstneeds R2
Unsafe Safe
WAIT
“If resource is free and with its allocation we can still guarantee that everyone will finish, use it.”
(�����������������:���-����������������
![Page 9: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/9.jpg)
Three Solutions to Deadlock…
#3: Mr./Ms. Liberal (Detection/Recovery)
time
Job starts Job finishes
R2R1
Job restarts
Deadlock detected
“If it’s free, use it -- why wait?”
��� ��������������:���������������������������5��� �� �����������1!
![Page 10: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/10.jpg)
Names for Three Methods on Last Slide
6;��+�� �����-������
� +������������������������������� �� ������������ � ���������
<;��+�� �����$��� ���
� +���������������������������������%��������� �����
���� ��� ��� �� �����������������%�������������!
� 9�%����������� ��������������%����������������������
���������!
=;��+�� �����+������� �9�������
� $���������� ���� �� ����
� 9��������������
![Page 11: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/11.jpg)
>�.��������� � ���������+�� ����
� ?�������������� .�/������������������
� 4�� �� �@��� $������������������� �������������� ����������������
� .�����/������ 9�������������������� ����������
� ��������@��
96 9<
-6
-<
![Page 12: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/12.jpg)
+�� �����-������
+������������������������������� ����
� -�����*?�������������,
� 5�������������������������
AB��2�����������������������������
![Page 13: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/13.jpg)
+�� �����-�������1
� -�����*4�� �� �@��,
C�; -���������� / ��������������%����� ����
������� �������������%���� �����������������������
�����������
C�; -���������������������������������������� �
����������� ���/��%�������������������%����
����������������
ABD������������
AB ��������E� ��������������E���F����
�� �������������������������������
![Page 14: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/14.jpg)
+�� �����-�������1
� $�����*9��������-�������,
� $����������������������%�����������������������
��������������������������� ���������� �
�������
AB #����������������������������� �������
�������������������C�!�!�������������� �����;
AB ?�����%�����F�����������
![Page 15: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/15.jpg)
+�� �����-�������1
� -����� ��������@��
� "� ��������������
� $�������%������������ �������������������
�� ��
![Page 16: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/16.jpg)
Preventing Circular Wait
Process:
Request:
A B C D A B C D
W X Y Z X Y Z W
A / W
B / X
C / Y
D / Z
Impose an ordering on Resources: 1 W2 X3 Y4 Z
Process D cannot request resource W without voluntarily releasing Z first
After first 4 requests:
![Page 17: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/17.jpg)
Problems with Linear Ordering Approach
C6;� $ ���������������������������� �����
��%����������� ���������������������������
�� ���� G�
C<;� 9��������������������������������
AB $����������������������%��������������������
����������� �����F�������������������%�������
�����������%�������������������� ���
��%����
![Page 18: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/18.jpg)
Deadlock Avoidance
� "#���������������������������������
������� ���� ��� �� ����
AB -�����������������"#����� �����
���������������������������
��%���
![Page 19: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/19.jpg)
Banker’s Algorithm
� (����H��$��������������������
� ������������%��������������/ 2����#���I
� ������������������/ ��2���������������� �������������������� � ����������������������I
� $������������������� �������������������������
��������������������������� �
AB ?���������������������������������� �
�/���������������J�����
![Page 20: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/20.jpg)
Definition: Safe State
� #�������������
� $�������������������������������� �����������������
����������%�������������������
� #�������
� .������������� �� ����� ��� �����������������������
��%����������������%������������� �� ��������� ������!
��������������
� .������������� �� ����� ��� ���������������������
��� ����� �� ����� ����
![Page 21: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/21.jpg)
+�� �����$��� ���
#����#���
�����K��������?���.��
-�������6 6 >
-�������< > L
-�������= M N
$���������A�<
![Page 22: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/22.jpg)
+�� �����$��� ���
5�����#���
�����K���������?���.��
-�������6 N 67
-�������< < M
-�������= 6 =
$���������A�6
![Page 23: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/23.jpg)
#������5������������
�����#����#���
�����K��������?�������.��
-�������6 6 >
-�������< > L
-������= M N �����������
#�������-�������=���%������ ���������������������
�����K��������?�������.��
5���6 6 >
5���< > L
5���= L N �����������
Current state being safe does not necessarily imply future states are safe
![Page 24: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/24.jpg)
(�����0���
� 2������������������������� �� �� �����!
� 2�������������������������� ��������������
�� ����!
� $��� ����� ������������������������������������������!�
![Page 25: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/25.jpg)
#�����5�������+�� �����#���
![Page 26: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/26.jpg)
(����O��$�������
� ?��������������������������!
� �������������������������������������������!
� @���������������%��������������������������������!��
� @���������������������������������������������������������������������!
����������"�������#����� �������L�� ��#���������:��������<77=
![Page 27: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/27.jpg)
+���#���������������(����O��$��������
� $��������� D��������������!�2������������PFQ�A������������� �����������������������9F���������!
� ?�������� �����!��2��?���P��FQ�A���������������-� ������%����������������������������������9F!
� $������������ � �����!��2��$�������P��FQ�A���� -� ������������������ �� ����������9F!
� .�� ����� � �����!�2��.�� P��FQ�A ����� -������� �� ���������������9F����������������!
.�� P��FQA�?��P��FQ�� $������� P��FQ!
Let n = number of processes, and m = number of resources types.
![Page 28: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/28.jpg)
#�����$�������
6! K��@����� �0���������������������� � �������������!��2�����:��
@����A�$��������
0�����P�Q�A ���������� A�6�<�=��1��!
<! 0� ������������������
C�;�0����P�Q�A������
C�;�.�� � ≤ @���2���������������������������>!
=!@��� A�@����R�$��������0����P�Q�A ������������<!
>! 2��0����P�Q�AA�������������������������������������������!
![Page 29: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/29.jpg)
#�����$�������
6! K��@����� �0���������������������� � �������������!��2�����:��
@����A�$��������
0�����P�Q�A ���������� A�6�<�=��1��!i=1;while (i <= n) Do {
if (!Finish[i] && Needi <= Work ) {Finish[i] = True;Work = Work + Allocationi;i = 1;
}else i++;
}
if (0����P�Q�AA���������������) return ( SAFE )else return ( UNSAFE );
![Page 30: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/30.jpg)
9�������/9�%����$������������-�������-�
9�%���A���%����������������������-�!��2��9�%���� PFQ�A�������������-� ����� �����������������������9F!6!2��9�%���� ≤ .�� � ���������<!��"����������������������� ��������������������������� � �����������������!
<!2��9�%���� ≤ $�������������������=!��"��������-� ���������������������������������������!
=!-��� �������������%���� �������������-� ����� ������������������������
$��������A�$���������/ 9�%����S
$��������A�$�������� R�9�%����S
.�� � A .�� � � 9�%����SS�2�������� ������������������������ ���-�!��2��������� -� ���������� ������ ���������/����������������������
![Page 31: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/31.jpg)
�����������(����O��$�������
� M�����������-7��������->S�=���������������$�C67�������;��(�CM�������;��� � �CT�������;!
� #�������������7�
$������� ?�� $��������
$�(� $�(� � $�(�
-7 7�6�7 T�M�=� =�=�<
-6 <�7�7� =�<�<��
-< =�7�<� U�7�<
-= <�6�6� <�<�<
-> 7�7�< >�=�=��
![Page 32: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/32.jpg)
��������C �!;
� �������������������!�.�� ��� ���� ������?�� � $�������!
.��
$�(�
-7 T�>�=�
-6 6�<�<�
-< L�7�7�
-= 7�6�6
-> >�=�6�
� ������������������������������������%�����
V�-6��-=��-7��-<��->B�����������������������!�
![Page 33: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/33.jpg)
��������-6 9�%����C6�7�<;�C �!;� ��������9�%���≤ $��������C�������C6�7�<;�≤C=�=�<;�� ���!
$������� .�� $��������
$�(� $�(� $�(� �
-7 7�6�7� T�>�=� <�=�7
-6 =�7�< 7�<�7�
-< =�7�6� L�7�7�
-= <�6�6� 7�6�6
-> 7�7�<� >�=�6�
� ����������������������������������%�����V-6��-=��-7��-<��->B������������������%������!�
� ����%��������C=�=�7;����-> ������� I
� ����%��������C7�<�7;����-7�������� I
![Page 34: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/34.jpg)
Banker's Algorithm: Summary
CR; -9"H��
� +�� ����������������!
� ?�������������&����������������� �� ������������!��C@��I;
C/;� ".H��
� ?������������������������������������F�������!
AB�.������� ��������������
� -���������������������������� �� ��������� �����������
![Page 35: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/35.jpg)
Deadlock Detection
Allow deadlock to occur, then recognize that it exists
� 9�� �� ����� ����������������������������
��������������%����
� ��� ��������� �����������������
![Page 36: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/36.jpg)
Resource Graphs
������������ ������ �� ����
.� ���
� ����
6;��-���������������������� <;��9��������
Pi Rj
Pi Rj6;��9�%���
<;��$������ Pi Rj
![Page 37: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/37.jpg)
Resource Graphs: Example
P1R1
P2 R2
P1 holds 2 units of R1P1 holds 1 unit of R2R1 has a total inventory of 4 unitsP2 holds 1 unit of R1P2 requests 1 unit of R2 (and is blocked)
![Page 38: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/38.jpg)
Operations on Resource Graphs:An Overview
6;�-���������%�����������������$ ����C�;
<;�-���������%������������������9����������C�;
=; -����������������������������+��������C�;
![Page 39: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/39.jpg)
Graph Reductions
� $������������ ��� ����������������������<�� �=�
C��������� ��������;
� $���������������������� ������������������������%�����
����� ����������� ����������������������������� �
� ��
� $���������-����� �� ����� ����� ���������������������
��%���������� ���������������-��������
� 2������������������������� ������������������������
���������������� �� �����
![Page 40: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/40.jpg)
Operations on Resource Graphs:Details
6;�-���%���������������C$ ����;-���� ����
� -���������������� �����%����
� -������%�����������������������������������
"�������
� $ ����� ���C�-� 9F ;�����������������������9F ��%����
<;�-���%����������������C9����������;-���� ����
� ?�������������������������������%����
� -���%������������%���� ����������
"�������
� 9������������%����� ���� ����� ������-����� ����������
![Page 41: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/41.jpg)
Operations on Resource Graphs: Details …
=; -��������������������C+��������;
-���� ����
� -���������������� �����%����
� -������������������������������������������ �
"�������
� +������������ ����� ������������������������������������ ���������
![Page 42: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/42.jpg)
Resource Graphs
P1 R1
P2R2
1) P1 acquires 1 unit of R12) P1 releases all resources (finishes)3) P2 acquires 2 units of R24) P2 releases all resources (finishes)
NO….One sequence of reductions:
DEADLOCKED?
![Page 43: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/43.jpg)
Resource Graphs …
P1 R1
P2R2
DEADLOCKED?
NO…. One sequence of Reductions:
1) P2 acquires 2 units of R22) P2 releases all resources (finishes)3) P1 acquires 2 units of R14) P1 releases all resources (finishes)
![Page 44: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/44.jpg)
Resource Graphs…
@�������������������<�����������������9<�I
�� �� ���������������������������������F��������������I
I
![Page 45: Chapter 10 Deadlock - Virginia Tech · 2002. 10. 31. · Three Solutions to Deadlock … #2: Mr./Ms. Prudent (Avoidance) time Job starts Job first needs R1 Job finishes R2 R1 Job](https://reader035.vdocuments.us/reader035/viewer/2022071404/60f9435a8d4362196b4e2d6d/html5/thumbnails/45.jpg)
Recovering from Deadlock
"��� �� ������������� ���� ������������������������ ������/ �� ����� ����
6;�W������������������������
/ ?�������� �����������������������!��� ��������� ��������������
<;�-���������������
/ -������ �����������������������
/ ?������������������������������������������