Consider processes as P0, P1, P2, P3, and resources as R0, R1, R2.
Given 2 Matrices Maximum Matrix C which shows the maximum number of resources of each type required by each process during its execution and the Allocation matrix A shows the current number of resources of each type allocated to each process
Resources available are [R0 R1 R2]=[5 8 15]
Need Matrix=Maximum Matrix-Allocation Matrix
Now we have,
| Maximum Matrix ( C) | Allocation Matrix (A) | Need Matrix | |||||||
| R0 | R1 | R2 | R0 | R1 | R2 | R0 | R1 | R2 | |
| P0 | 4 | 1 | 4 | 0 | 1 | 4 | 4 | 0 | 0 |
| P1 | 3 | 1 | 4 | 2 | 0 | 1 | 1 | 1 | 3 |
| P2 | 5 | 6 | 13 | 1 | 2 | 1 | 4 | 4 | 12 |
| P3 | 1 | 1 | 6 | 1 | 0 | 3 | 0 | 1 | 3 |
and by the mentioned in the question, the system is in a safe state for now.
The processes and resources are indexed from 0.
Checking whether a request by process p1 for 2 units of resource 2 can be safely granted or not:
P1 requests [R0 R1 R2]=[0 0 2] i.e., process 1 requests 2 units of resource 2.
Available Resources [R0 R1 R2]=[5 8 15]
Clearly,
The instances available currently, the requirements or requests of process1 P1 can be satisfied.
So Bankers algorithm assumes that the request from process 1 is entertained and then it modifies the matrix as
Note: Modified data is represented in Bold
| Maximum Matrix ( C) | Allocation Matrix (A) | Need Matrix | |||||||
| R0 | R1 | R2 | R0 | R1 | R2 | R0 | R1 | R2 | |
| P0 | 4 | 1 | 4 | 0 | 1 | 4 | 4 | 0 | 0 |
| P1 | 3 | 1 | 4 | 2 | 0 | 3 | 1 | 1 | 1 |
| P2 | 5 | 6 | 13 | 1 | 2 | 1 | 4 | 4 | 12 |
| P3 | 1 | 1 | 6 | 1 | 0 | 3 | 0 | 1 | 3 |
Now Available resources are
[5 8 15] - [0 0 2] = [5 8 13]
Now, it follows the safety algorithm to check whether this resulting state is a safe state or not.
if it is a safe state, then the request can be safely permitted otherwise not.
Step 1:
Then available instances are
= [5 8 13] + [0 1 4]
= [5 9 17]
Step 2:
Then available instances are
= [5 9 17] + [2 0 3]
= [7 9 20]
Step 3:
Then available instances are
= [7 9 20] + [1 2 1]
= [8 11 21]
Step 4:
Then available instances are
= [8 11 21] + [1 0 3]
= [9 11 24]
Thus ,
There exists a safe sequence P0-->P1-->p2-->P3 in which all processes are executed.
So,The system is in a safe state.
Thus, The request by process 1 can be safely granted.
Part B (10) Deadlock Avoidance Consider the following maximum-claim reusable resource system with four processes and...
a. A system has two processes and three identical resources. Each process needs a maximum of two resources. Is deadlock possible? Explain your answer. b. A system has 4 processes, P1 through P4, and 5 types of resources, R1 through R5. Existing resource vector E = (3, 2, 1, 2, 2) Current allocation matrix C = R1 R2 R3 R4 R5 P1 1 1 0 0 0 P2 0 0 1 0 0 P2 1 0 0 20 P4 0...
T/F question about operating system, thank you 1. A deadlocked system must involve at least two threads/processes that are deadlocked. 2. If all 4 following conditions hold in a system: mutual exclusion, hold and wait, circular waiting, and no pre-emption, then a deadlock must occur. 3. In avoidance strategy, the OS may refuse to allocate requested resources if there is a potential for a deadlock. 4. Given a reusable resource graph representing a state S, state S is a deadlock...
resource instances of the same type, being shared by processes maz, is maximum resource needs of Pi, where 2 mar, S m n. Assume that a process can request one resource at a time during execution. Answer 7. (20 pts) Consider a system of m P, P Pa where m 22. Suppose the following questions about deadlock among the various processes A: Suppose m 5 printers and n 2 processes in a system, with mazi 3 and mar2 4. Identify...
A system has five processes P1 through P5 and four resource types R1 through R4. There are 2 units of each resource type. Given that: P1 holds 1 unit of R1 and requests 1 unit of R4 P2 holds 1 unit of R3 and requests 1 unit of R2 P3 holds one unit of R2 and requests 1 unit of R3 P4 requests 1 unit of R4 P5 holds one unit of R3 and 1 unit of R2, and requests...
Please give an explanation for the answers as well. 1. A system has three processes (P1, P2, and P3) and three resources (R1, R2, and R3). There is one instance of RI, two instances of R2, and three instances of R3. PI holds RI and one instance of R3 and is requesting one instance from R2. P2 holds one instance of R3 and is requesting RI and one instance from R2. P3 holds two instances of R2 and one instance...
Consider a system in which four processes (A,B,C,D) are attemptign to access four types of resource (1,2,3,4). There are two instances of each type of resource , and the current allocation is <1001> for A , <0101> for B , <1000> for C , and <0010> for D. The Max Need for each process is <2002> for A , <0202> for B , <1100> for C , and <1010> for D. Is this system state safe? If so give an...
In order to prevent deadlocks, let a system adopt the policy of forcing processes to request resources in ascending order of request type rank. In particular, when a process is requesting a resource of a certain type, the process cannot be holding other higher ranked resources. Consider four resource types with the following profile in this system: Resource Type Rank Number of Instances RT1 4 2 RT2 7 4 RT3 8 3 RT4 10 2 Let the following sequence of...
Write a C program for:
One technique for dealing with deadlock is called “detect and
recover.” In this scheme, some procedure is used
to identify when a deadlock occurs, and then another procedure
is used to deal with the blocked processes. One technique to
identify a deadlock is to maintain a resource graph that identifies
all processes, all resources, and the relationships between them
(that is, which processes exclusively own which resources, and
which processes are blocked waiting for which...
Consider the following snapshot of a system: Allocation P R1 R2 R3 R4 P1 0 0 1 2 P2 1 0 0 0 P3 1 3 5 4 P4 0 6 3 2 P5 0 0 1 4 P represents processes R represents resources Need P R1 R2 R3 R4 P1 0 0 1 2 P2 1 7 5 0 P3 2 3 5 6 P4 0 6 5 2 P5 0 6 5 6 P represents processes R represents...
Q.6. Consider a preemptive operating system where processes have priorities and a running process gets preempted (i.e., forced to leave the CPU) as soon as a higher priority process is ready to run. The life cycle of a process, other than the very first process, begins with a "spawn" by another process and ends with either a regular "exit" by the process or a "terminate (process_id)" command by another process of equal or higher priority. COMP 346 – Fall 2019...