week 10 assign 8

Shared by: 8K9nPz3
Categories
Tags
-
Stats
views:
9
posted:
6/9/2012
language:
English
pages:
2
Document Sample
scope of work template
							                             King Saud University
                 College of Computer and Information Sciences
                       Information Technology Department

                             Second Semester 1432/1433
                                       IT 421
                                   Assignment #8
Homework policy:
1) Copying any part of other people's code, solution sets, or from any other sources is
strictly prohibited.
2) If your source is the web, write your references in details.
3) Solutions quality (understandable and organized document, not handwriting).


Q1) Given the following state for the Banker’s Algorithm.

     •   5 processes P0 through P4
     •   3 resource types A (6 instances), B (9 instances) and C (5 instances).

     •   Snapshot at time T0:

                                      Max               Allocation
                                   A   B   C             A   B   C
                        P0         6   7   3             1   1   1
                        P1         2   2   2             1   1   2
                        P2         2   6   3             0   3   0
                        P3         2   2   2             2   1   1
                        P4         4   6   3             1   1   1

a)       Calculate the available vector.

b)       Calculate the Need matrix.

                               Need
                              A B C
                  P0

                  P1

                  P2

                  P3

                  P4
c)      Is the system in a safe state? If so, show one sequence of processes which allows
the system to complete. If not, explain why. Show your computation step-by-step;
otherwise, you will receive no credit.

d)      Given the request (1, 2, 0) from Process P2. Should this request be granted? Why
or why not? Show your computation step-by-step; otherwise, you will receive no
credit.



Q2) A system has three processes (P1, P2, P3) and three reusable resources (R1, R2, R3).
There is one instance of R1, two instances of R2 and three instances of R3. P1 holds an R1
and an R3 and is requesting an R2. P2 holds an R3 and is requesting an R1 and an R2. P3
holds two R2 and an R3 and is requesting an R1.

a) Draw the resource allocation graph for this situation.

b) Write all the cycle(s) in the graph.

c) Does a deadlock exist? Why?



Q3) A computer has three commonly used resources designated A, B and C. Up to three
processes designated X, Y and Z run on the computer and each makes periodic use of two
of the three resources.

      Process X acquires A, then B, uses both and then releases both.
      Process Y acquires B, then C, uses both and then releases both.
      Process Z acquires C, then A, uses both and then releases both.

a) If two of these processes are running simultaneously on the machine, can a deadlock
occur? If so, describe the deadlock scenario.

b) Describe a scenario in which deadlock occurs if all three processes are running
simultaneously on the machine.

c) Modify the algorithm for acquiring resources so that deadlock cannot occur with three
processes running.

						
Related docs
Other docs by 8K9nPz3