Question

In: Computer Science

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

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

P0 0 0 1 2 0 0 1 2 1 5 2 0

P1 1 0 0 0 1 7 5 0

P2 1 3 5 4 2 3 5 6

P3 0 6 3 2 0 6 5 2

P4 0 0 1 4 0 6 5 6

Answer the following questions using the banker’s algorithm: a. What is the content of the matrix Need? b. Is the system in a safe state? Demonstrate the reason for your answer. c. If a request from process P1 arrives for (0,4,2,0), can the request be granted immediately? Demonstrate the reason for your answer.

Solutions

Expert Solution

Given:

Allocation:

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

Max:

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

Available:

A B C D
1 5 2 0

a)

Need matrix is calculated as follows:

Need=Max-Allocation

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

b)

To check whether this system is in safe state.

We have available vector as:

Available:

A B C D
1 5 2 0

We can see from the need matrix that process P0 does not need any further resources and therefore, it can complete its execution and release the allocated resources.

Therefore, the available now becomes:

A B C D
1 5 3 2

Now, from the need matrix we can see that process P2 can be given the available resources so that process P2 completes its execution and release the resources allocated to it.

Therefore, the available now becomes:

A B C D
2 8 8 6

Now, from the need matrix it is clear that the remaining processes, P1 P3 P4, can be executed with the current available resources.

After executing Process P1

The available now becomes:

A B C D
3 8 8 6

After executing Process P3

The available now becomes:

A B C D
3 14 11 8

After executing Process P4

The available now becomes:

A B C D
3 14 12 12

Yes, the system is in safe state. The safe sequence is P0 P2 P1 P3 P4.

c)

If the request by P1(0,4,2,0) is approved, then the allocation matrix, need matrix and available will become as follows:

Allocation:

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

Need:

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

Available:

A B C D
1 1 0 0

P0 does not require any further resources. Therefore, P0 gets executed completely and releases the allocated resources.

Therefore, available becomes;

A B C D
1 1 1 2

Now, P2 can be executed.

Therefore, available becomes:

A B C D
2 4 6 6

Now, P1 can be executed.

Therefore, available becomes:

A B C D
3 8 8 6

Now, both the processes can be executed.

P3 gets executed

Therefore, available becomes:

A B C D
3 14 11 8

P4 gets executed

Therefore, available becomes:

A B C D
3 14 12 12

Therefore, the system remains in safe state with the safe sequence P0 P2 P1 P3 P4.


Related Solutions

Consider the following snapshot of a system: Allocation                   Max                 Availa
Consider the following snapshot of a system: Allocation                   Max                 Available A B C D              A B C D                    A B C D P0                    0 0 1 2                0 0 1 2                      1 5 2 0 P1                    1 0 0 0                1 7 5 0 P2                    1 3 5 4                2 3 5 6 P3                    0 6 3 2                0 6 5 2 P4                   0 0 1...
Consider the following snapshot of a system that has four resource types: A, B, C, and...
Consider the following snapshot of a system that has four resource types: A, B, C, and D and five processes, P0, P1, P2, P3, and P4. Allocation Max A B C D A B C D P0 3 0 1 5 5 1 1 7 P1 2 2 1 0 3 2 1 1 P2 3 1 2 1 3 3 2 1 P3 0 5 1 0 4 6 1 2 P4 4 2 1 3 6 3 2...
Consider the following snapshot of a system:
Consider the following snapshot of a system:           Allocation       Max          Available             ABCD         ABCD           ABCDT0        3141           6473            2224T1        2102           4232 T2        2413           2533 T3        4110           6332T4       ...
Consider the following propositional formula: (((A ^ B) -> C) ^ ((A ^ C) -> D))...
Consider the following propositional formula: (((A ^ B) -> C) ^ ((A ^ C) -> D)) -> ((A ^ B) -> D) Perform the following tasks for this formula: Convert this formula into CNF form and write a numbered list of all clauses obtained from this formula.
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what...
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what proportion of the progeny will phenotypically resemble the first parent? b) what proportion of the progeny will genotypically resemble neither parent?
MIPS a) Consider the C statement: a = (b + d) + (b - c) +...
MIPS a) Consider the C statement: a = (b + d) + (b - c) + (c + d) Which of the following assembly instructions can be used to replicate all or part of this statement in MIPS, without changing or reducing the equation. Assume variables a, b, c, and d are assigned to registers $s0, $s1, $s2 and $s3 respectively. 1. sub $t0, $s2, $s3 2. sub $t0, $s0, $s3 3. sub $t1, $s1, $s2 4. sub $t2, $s1,...
The following table gives the available projects (in $millions) for a firm. A B C D...
The following table gives the available projects (in $millions) for a firm. A B C D E F G 90 20 60 50 150 40 20 Initial investment 140 70 65 −10 30 32 10 NPV If the firm has a limit of $210 million to invest, what is the maximum NPV the company can obtain? Explain how you decided to prioritize the projects (i.e. use Profitability Index or just reference NPV)
Consider this set A = { a, b, c, d } and the following relations R6...
Consider this set A = { a, b, c, d } and the following relations R6 = { ( a, a ), ( a, b), ( b, b), ( c, d ) } R7 = { ( a, a), ( b, b ), ( b, c ), ( c, c ), ( c, d), (d, d) } R8 = { (a, b), (a, d), ( b, a), ( d, a) , ( b, d) , (d, b) } R9 =...
Consider a project consisting of four activities A, B, C, and D. The following are constraints...
Consider a project consisting of four activities A, B, C, and D. The following are constraints within which the project has to be conducted • A and B, the first activities of the project, can be started simultaneously. • C can be started only after A is completed. • D can be started only after B is completed Suppose the activity times for the activities are A = 4 weeks, B = 3 weeks, C = 2 weeks, D =...
Consider the following reaction at 309 K. 1 A + 1 B → C + D...
Consider the following reaction at 309 K. 1 A + 1 B → C + D where rate = rate=k[A]2[B]. An experiment was performed for a certain number of seconds where [A]o = 1.07 M and [B]o = 0.000167 M. A plot of ln[B] vs time had a slope of -9.63. What will the rate of this reaction be if a new experiment is preformed when [A] = [B] = 0.212 M?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT