
The wait-for graph scheme is not applicable to a resource-allocation system with multiple instances of each
resource type. We need a deadlock detection
several time-varying data structure that are similar to those used in the banker’s algorithm.
Available. A vector of length ? indicates the number of available resources of each type.
Allocation: An ? × ? matrix defines the number of resources of each type currently allocated to each
thread
Request: An ? × ? matrix indicates the current request of each thread. If Request[i][ j] equals ?, then
thread ?i is requesting ? more instances of resource type ?j
The ≤ relation between two
Let ? and ? be vectors of length ?. We say that ? ≤ ? if and only if ?[?] ≤ ?[?] for all ? = 1,2, . . , ?. For example,
if ? = (1,7,3,2) and ? = (0,3,2,1), then ? ≤ ?. In addition, ? < ? if ? ≤ ? and ? ≠ ?.
We can treat each row in the matrices ?????????? and ??????? as vectors and refer to them as ???????????
and ????????. The vector ??????????? specifies the resources currently allocated to thread ?i; the vector ????????
specifies the resources requested by thread ?i.
This detection algorithm simply investigates every possible allocation sequence for the threads that remain to be
completed. The following is the Deadlock Detection algorithm we want to study in this assignment.
1. Let Work and Finish be vectors of length m and n, respectively. Initialize Work = Available. For i = 0, 1, ..., n-1, if Allocation, # 0, then Finish i] = false. Otherwise, Finish|i] = true.
2. Find an index i such that both
a. Finishi] == false
b. Request; ≤ Work
If no such i exists, go to step 4.
3. Work = Work + Allocation;
Finish il = true
Go to step 2.
4. If Finish[i] == false for some i, 0 <i < n, then the system is in a deadlocked state. Moreover, if Finish i] == false, then thread T, is deadlocked.
1. Solve the following problem. Consider a system with five threads ?? through ?? and three resource types
A, B, and C. Resource type A has seven instances, resource type B has two instances, and resource type C has
six instances.
?????????? ??????? ?????????
A B C A B C A B C
?0 0 1 0 0 0 0 0 0 0
?1 2 0 0 2 0 2
?2 3 0 3 0 0 0
?3 2 1 1 1 0 0
?4 0 0 2 0 0 2
1) Answer whether the system below is in the deadlock state. If there does not exist a deadlock state, solve the problem using the algorithm presented above and write down the process in detail and find the sequence in which the system works without a deadlock. If there exists a deadlock, write down all the threads, consisting of the deadlock.
2) Suppose now that ?2 makes one additional request for an instance of type C. That is, the ??????? matrix is modified as follows:
???????
A B C
?0 0 0 0
?1 2 0 2
?2 0 0 1
?3 1 0 0
?4 0 0 2
Answer whether the system below is in the deadlock state. If there does not exist a deadlock state, solve
the problem using the algorithm presented above and write down the process in detail and find the
sequence in which the system works without a deadlock. If there exists a deadlock, write down all the
threads, consisting of the deadlock

Trending nowThis is a popular solution!
Step by stepSolved in 9 steps

- In pythion with numpy I have code in a for loop that creates a vecor of 12 elements:x = 1 2 3 4 5 6 7 8 9 10 11 12 The loop iterates 10 times. The second iteration generates a new vector x = 12 11 10 9 8 7 6 5 4 3 2 1 etc. At the end of the loop I need to have a 12 X 10 matrix x x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x x I cannot figure out how to createa matrix where it takes the output and uses the output as rowarrow_forwardSuppose you are in Canada's Thousand Islands National Park, and in one particular lake there are n small islands that park officials want to connect with floating bridges so that people can experience going between islands without a canoe. The cost of constructing a bridge is proportional to its length. Assume the distance between every pair of islands is given to you as a two dimensional matrix (an example of such a table for n = 8 islands is shown below). A B C Ꭰ E F G H A 240 210 340 280 200 345 120 B 240 265 175 215 180 185 155 C 210 265 - 260 115 350 435 195 Ꭰ 340 175 260 160 330 295 230 E 280 215 115 160 360 400 170 F 200 180 350 330 360 175 205 G 345 185 435 295 400 175 305 H 120 155 195 230 170 205 305 Design an algorithm for determining which bridges they should build to connect the islands at minimal cost. Write down the pseudocode and explain why your algorithm correctly computes the set of bridges of minimal cost. Analyze the runnning time of your algorithm.arrow_forwardType in Latex **Problem**. Let $$A = \begin{bmatrix} .5 & .2 & .3 \\ .3 & .8 & .3 \\ .2 & 0 & .4 \end{bmatrix}.$$ This matrix is an example of a **stochastic matrix**: its column sums are all equal to 1. The vectors $$\mathbf{v}_1 = \begin{bmatrix} .3 \\ .6 \\ .1 \end{bmatrix}, \mathbf{v}_2 = \begin{bmatrix} 1 \\ -3 \\ 2 \end{bmatrix}, \mathbf{v}_3 = \begin{bmatrix} -1 \\ 0 \\ 1\end{bmatrix}$$ are all eigenvectors of $A$. * Compute $\left[\begin{array}{rrr} 1 & 1 & 1 \end{array}\right]\cdot\mathbf{x}_0$ and deduce that $c_1 = 1$.* Finally, let $\mathbf{x}_k = A^k \mathbf{x}_0$. Show that $\mathbf{x}_k \longrightarrow \mathbf{v}_1$ as $k$ goes to infinity. (The vector $\mathbf{v}_1$ is called a **steady-state vector** for $A.$) **Solution**. To prove that $c_1 = 1$, we first left-multiply both sides of the above equation by $[1 \, 1\, 1]$ and then simplify both sides:$$\begin{aligned}[1 \, 1\, 1]\mathbf{x}_0 &= [1 \, 1\, 1](c_1\mathbf{v}_1 +…arrow_forward
- write a C++ program to Given a matrix of dimension m*n where each cell in the matrix can have values 0, 1 or 2 whichhas the following meaning:0: Empty cell1: Cells have fresh oranges2: Cells have rotten orangesSo we have to determine what is the minimum time required so that all the oranges becomerotten. A rotten orange at index [i,j] can rot other fresh orange at indexes [i-1,j], [i+1,j], [i,j-1],[i,j+1] (up, down, left and right). If it is impossible to rot every orange then simply return -1.Examples:Input: arr[][C] = { {2, 1, 0, 2, 1},{1, 0, 1, 2, 1},{1, 0, 0, 2, 1}};Output:All oranges can become rotten in 2 time frames.Input: arr[][C] = { {2, 1, 0, 2, 1},Tahir Iqbal Department of Computer Sciences. BULC{0, 0, 1, 2, 1},{1, 0, 0, 2, 1}};Output:All oranges cannot be rotten.Below is algorithm.1) Create an empty Q.2) Find all rotten oranges and enqueue them to Q. Also enqueuea delimiter to indicate beginning of next time frame.3) While Q is not empty do following3.a) While delimiter in…arrow_forwardQuestion 2: The game of "FastestPath" consists of a path (a 1-D array) with n positive integers to represent n cities in a path (except the first index which has always value 0). The aim of the game is to move from the source city (located at index 0) to destination (located at last index) in the shortest time. The value at each index shows the travel time to enter the city located in the corresponding index. Here is a sample path where there are 6 cities (n is 6): 0 5 90 7 61 12 Always start the game from the first city and there are two types of moves. You can either move to the adjacent city or jump over the adjacent city to land two cities over. The total travel time of a game is the sum of the travel times of the visited cities. In the path shown above, there are several ways to get to the end. Starting in the first city, our time so far is 0. We could travel to city 2, then travel to city 4, then travel to last city for a total travel time of 90 + 61 + 12 = 163. However, a…arrow_forward3arrow_forward
- Using Java Modify the program 1 in guided activity 3 to compute the multiplication of two vectors with the sizes 1xn and nx1. The result is a number (one element matrix) computed as the sum of the products of the corresponding elements from the first vector with the ones from the second vector: m1[0][0]m2[0][0]+m1[0][1]*m2[1][0]+...+m1[0][n-1]m2[n-1][0arrow_forwardConsider a situation of a boarding gate of a plane where passengers are allowed to board on the place based on their age. All passengers are on a line (queue) to board on the place, however, the oldest one is always allowed to board first no matter when he/she got in the line (queue). In this case, you cannot sort the passengers by their age, however, you know that oldest ones are always at the top of the line. This is an example of a priority queue where data will be accessed and processed based on their level of priority. Suppose you need to organize such type of data so that the data in highest priority can be accessed in a constant time, O(1). What type of data structure would you use in such cases? Justify your answer.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





