Question

In: Computer Science

1. Assume we have the following resources: • 4 graphic displays • 3 printers • 1...

1. Assume we have the following resources: • 4 graphic displays • 3 printers • 1 disks Consider we have already allocated these resources among four processes as demonstrated by the following matrix named Allocation. Process Name Graphics Printers Disk Drives Process A 0 1 0 Process B 0 0 1 Process C 0 1 0 Process D 1 0 0 The following is the matrix to show the number of each resources requested; we call this matrix Request. Process Name Graphics Printers Disk Drives Process A 2 0 0 Process B 2 2 0 Process C 1 0 1 Process D 0 2 1 a. Apply Deadlock Detection Algorithm and check whether any deadlock exists. b. Suppose now the Process B requests one additional instance of Graphics, and Process C requests two additional instances of Graphics and one additional instance of Disk Drives, whether this can be granted?

Solutions

Expert Solution

a.

The allocation matrix :

Process Graphic Display Printer Disk
A 0 1 0
B 0 0 1
C 0 1 0
D 1 0 0

Total number of resources in the system :

4 Graphic Displays, 3 Printers and 1 disks.

The available vector is obtained by subtracting the sum of all instances of a device from the total number of instances present for that device.

So, the available vector is :

Graphic Display Printer Disk
3 1 0

The need matrix is :

Process Graphic Display Printer Disk
A 2 0 0
B 2 2 0
C 1 0 1
D 0 2 1

The deadlock detection algorithm refers to the safety algorithm as follows :

Step 1 :

Initialize a variable Work = Available = 3 1 0  

Initialize a boolean array variable flag[i] = false for all processes i = A, B. C and D.

Step 2 :

Find a process such that the need value of the process is less than the work vector and flag value is false.

The process selected is process A.

Update the value of Work as Work = Old value of Work + Allocation value of process A

= 3 1 0 + 0 1 0 = 3 2 0

Assign flag value for process A as true.

Step 3 :

Find a process such that the need value of the process is less than the work vector and flag value is false.

The process selected is process B.

Update the value of Work as Work = Old value of Work + Allocation value of process B

= 3 2 0 + 0 0 1

= 3 2 1

Assign flag value for process B as true.

Step 4 :

Find a process such that the need value of the process is less than the work vector and flag value is false.

The process selected is process C.

Update the value of Work as Work = Old value of Work + Allocation value of process C

= 3 2 1 + 0 1 0

= 3 3 1

Assign flag value for process C as true.

Step 5 :

Find a process such that the need value of the process is less than the work vector and flag value is false.

The process selected is process D.

Update the value of Work as Work = Old value of Work + Allocation value of process D

= 3 3 1 + 1 0 0

= 4 3 1

Assign flag value for process D as true.

Since the values of all processes are true, the resultant safe sequence is A, B, C and D and hence, there is no deadlock.

b.

Process B has requested for 1 instance of Graphic Display. Process C has requested 2 instances of Graphic Displays and one instance of Disk.

Applying Banker's algorithm :

For process B,

  • Request vector which is 1 0 0 is less than or equal to Need vector which is 2 2 0.
  • Request vector as of now for process B will be 1 0 0 and it is less than or equal to value of available which is 3 1 0. So, proceed to the next step.
  • Available vector = Available vector old value - Request vector of process B that is 3 1 0 - 1 0 0 = 2 1 0.
  • Allocation value of process B = Old allocation value + Request vector of process B that is 0 0 1 + 1 0 0 = 1 0 1.
  • Need value of process B = Old value of Need - Request vector of process B that is 2 2 0 - 1 0 0 = 1 2 0.

For process C,

  • Request vector which is 2 0 1 is more than the Need vector which is 1 0 1. So, this results in an error and the algorithm cannot proceed.

Hence, collectively if process B and process C requests for the given resources, then the request cannot be granted.


Related Solutions

1.We have learned that bond prices move inversely to interest rates as shown in this graphic....
1.We have learned that bond prices move inversely to interest rates as shown in this graphic. Why is this true? Please explain your answer thoroughly.   2. The Margaret Anne Dance Company issued a $1,000, 30-yr bond 4 years ago with a 4.0% coupon that pays semiannually. The bond is currently priced at $1,040. What is the Yield to Maturity (YTM) of this bond? 3. If the Yield to Maturity (YTM) changes to 4.75%, what is the new price of the...
Assume that as of August 1, 3,000 units of flat panel displays have been produced and...
Assume that as of August 1, 3,000 units of flat panel displays have been produced and sold during the current year. Analysis of the domestic market indicates that 2,000 additional units are expected to be sold during the remainder of the year at the normal product price determined under the product cost method. On August 3, Crystal Displays Inc. received an offer from Maple Leaf Visual Inc. for 600 units of flat panel displays at $226 each. Maple Leaf Visual...
1. Assume you have the following cashflows Time: 0 1 2. 3 4 5 Cf: 21...
1. Assume you have the following cashflows Time: 0 1 2. 3 4 5 Cf: 21 4 5 6. 6(1 + .02). 6(1+.02)^2 After year 3 cashflows will grow by constant 2% rate What is the discounted present value of these cashflows if your project's cost of capital is 13%?
1) The following table depicts the output of a firm that manufactures computer printers. The printers...
1) The following table depicts the output of a firm that manufactures computer printers. The printers sell for $100 each. Calculate Marginal Revenue Product for each level of labor Labor Input (Weekly)            Output 10 200 11 218 12 234 13 248 14 260 15 270 16 278 2) Refer back to your answers to Problem1 in answering the following questions. What is the maximum wage the firm will be willing to pay if it hires 15 workers? The weekly...
Question 1 of 4 A family plans to have 3 children. For each birth, assume that...
Question 1 of 4 A family plans to have 3 children. For each birth, assume that the probability of a boy is the same as the probability of a girl. What is the probability that they will have three children of the same gender? A- 0.5 B- 0.25 C- 0.375 D-0.125 E-none of these Question 2 of 4 A person in a casino decides to play blackjack until he loses a game, but he will not play more than 3...
Assume we roll a fair four-sided die marked with 1, 2, 3 and 4. (a) Find...
Assume we roll a fair four-sided die marked with 1, 2, 3 and 4. (a) Find the probability that the outcome 1 is first observed after 5 rolls. (b) Find the expected number of rolls until outcomes 1 and 2 are both observed. (c) Find the expected number of rolls until the outcome 3 is observed three times. (d) Find the probability that the outcome 3 is observed exactly three times in 10 rolls given that it is first observed...
Assume we have a society with 1 producer and 1 consumer and we are looking at...
Assume we have a society with 1 producer and 1 consumer and we are looking at the market for coconuts. Let us simplify further and assume that the producer can harvest only 1 coconut with a marginal cost of $5. The marginal benefit to the consumer for the coconut is $10. From question b and onwards, assume the two economic agents agree to a price of $9 for the coconut. What is the maximum possible price for these two agents...
An office has 4 panasonic 6 brother and 3 HP printers. it is known that time...
An office has 4 panasonic 6 brother and 3 HP printers. it is known that time before major printer failure is normally distributed with means 60, 80, and 85 days for panasonic, brother, and hp brands respectively. the standard deviation of time before major failure are 10, 10 and 12 days, respectively for the said brands. A. Five printers are selected at random. what is the probability that at most 2 brother printers are chosen? B. what is the expected...
Assume that you have a fair 6 sided die with values {1, 2, 3, 4, 5,...
Assume that you have a fair 6 sided die with values {1, 2, 3, 4, 5, 6} and a fair 12 sided die with values {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}. A discrete random variable is generated by rolling the two dice and adding the numerical results together. (a) Create a probability mass function that captures the probability of all possible values of this random variable. You may use R or draw the pmf...
1. Assume we have 8 registers, R0~R7, and we have a pipeline of 6 stages: Instruction...
1. Assume we have 8 registers, R0~R7, and we have a pipeline of 6 stages: Instruction Fetch (IF), Instruction Issue (II), Operands Fetch (OF), Execution (EX), Write Back (WB), and Commitment (CO). Each stage needs exactly 1 cycle to finish its work. Also assume that the pipeline supports forwarding, which means the result of WB can be forwarded to OF. Given the following piece of instructions: R1 = R0 + R2 R3 = R4 + R5 R6 = R1 +...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT