Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following snapshot of a system: Allocation Max Available A B C D A

ID: 3551697 • Letter: C

Question

Consider the following snapshot of a system:


        Allocation        Max            Available

      A B C D     A B C D     A B C D

P0 3 0 1 1       6 5 5 1      1 2 3 0

P1   1 1 0 1       2 2 2 1

P2   1 1 1 1       4 3 4 2

P3   2 1 1 1       2 5 4 2

P4   1 0 1 0       2 0 1 1



Answer the following questions using banker's algorithm:


a.) Show the content of the NEED matrix below.


b.) Show that the system in a safe state by listing the order in which processes can be executed without producing a deadlock.


c.) If a request from process P0 arrives for (0,2,2,0), can the request be granted immmediately? Show the updated NEED and Allocation matrices. If yes, show the safe sequence. If no, list the processes that are possbily in deadlock.

Explanation / Answer

a.) Show the content of the NEED matrix below



b.) Show that the system in a safe state by listing the order in which processes can be executed without producing a deadlock.


AS available is 1 2 3 0 and need of P1 is 1 1 2 0 we can perform process P1 now

after completion of P1 the allocated resorces of P1 will be available as the process is completed so...

new available is =old avilable + allocated of P1

                             =1 2 3 0 + 1 1 0 1

                              =2 3 3 1


as available is 2 3 3 1 and need of P4 is 1 0 0 1 we can perform P4

after completion of P4 the allocated resorces of P4 will be available as the process is completed so.

similarly now new available is =old avilable + allocated of P4

                                                       =2 3 3 1 + 1 0 1 0

                                                       = 3 3 4 1


now available is 3 3 4 1 we can perform P2 as need of P2 is 3 2 3 1

after completion of P2 the allocated resorces of P2 will be available as the process is completed so.

similarly now new available is =old avilable + allocated of P2

                                                       =3 3 4 1 + 1 1 1 1

                                                       = 4 4 5 2


now available is 4 4 5 2 we can perform P3 as need of P3 is 0 4 3 1

after completion of P3 the allocated resorces of P3 will be available as the process is completed so.

similarly now new available is =old avilable + allocated of P3

                                                       =4 4 5 2 + 2 1 1 1

                                                       = 6 5 6 3


now available is 6 5 6 3 we can perform P0 as need of P0 is 3 5 4 0

after completion of P0 the allocated resorces of P0 will be available as the process is completed so.

similarly now new available is =old avilable + allocated of P)

                                                       =6 5 6 3 + 3 0 1 1

                                                       = 9 5 7 4


sequence is P1 --P4--P2--P3--P0


so the system is is safe state



c.) If a request from process P0 arrives for (0,2,2,0), can the request be granted immmediately? Show the updated NEED and Allocation matrices. If yes, show the safe sequence. If no, list the processes that are possbily in deadlock.




new available = oldavailable - request

                = 1 2 3 0 - 0 2 2 0

               =1 0 1 0


new need = old need -request (for P0--as request is made by P0)

          =3 5 4 0 - 0 2 2 0

          = 3   3    2    0



new allocated= old allocated + request (for P0--as request is made by P0)

                         =3   0   1    1 + 0    2    2    0

                        =3    2    3   1


new need matrix after request is....



as available is 1 0 1 0 after request is granted


now we can see that none of the process can be processed as for every process ....need (Process i ) > available

so request can not be granted immediatly.

all the processes will be in deadlock (P0 P1 P2 P3 P4 )




NEED


A B C D P0 3 5 4 0 P1 1 1 2 0 P2 3 2 3 1 P3 0 4 3 1 P4 1 0 0 1