Question

In the code below, three processes are competing for six resources labeled A to F. a....

In the code below, three processes are competing for six resources labeled A to F.

a. Determine a sequence of requests and locks that results in a deadlock among the 3 processes. You could, for example, for each process list which resources it currently has locked (Allocated) and which resource it is requesting. Hint: it might be useful to draw a resource allocation graph to help you find a deadlock.

b. Modify the order of some of the get requests to prevent the possibility of any deadlock. You cannot move requests to another process, only change the order inside each one.

void P0()
{
while (true) {
get(A);
get(B);
get(C);
// critical region:
// use A, B, C
release(A);
release(B);
release(C);
}
}

void P1()
{
while (true) {
get(D);
get(E);
get(B);
// critical region:
// use D, E, B
release(D);
release(E);
release(B);
}
}

void P2()
{
while (true) {
get(C);
get(F);
get(D);
// critical region:
// use C, F, D
release(C);
release(F);
release(D);
}
}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
In the code below, three processes are competing for six resources labeled A to F. a....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a. A system has two processes and three identical resources. Each process needs a maximum of...

    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...

  • In order to prevent deadlocks, let a system adopt the policy of forcing processes to request...

    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...

  • Please give an explanation for the answers as well. 1. A system has three processes (P1,...

    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...

  • Let I represent an execution of init(s), W of wait(s), and S of signal(s). Then, for...

    Let I represent an execution of init(s), W of wait(s), and S of signal(s). Then, for example, IWWS represents the sequence of calls init(s), wait(s), wait(s), and signal(s) by some processes in an operating system. For each of the following sequences of calls, state the value of s and the number of processes blocked after the last call in the sequence: (b) IS (c) ISSSW (d) IWWWS (e) ISWWWW Each of the following code fragments contains a bug in the...

  • Compile and run the deadlockFree.c program below and report if this program does go into deadlock...

    Compile and run the deadlockFree.c program below and report if this program does go into deadlock or not. Modify this deadlockFree.c program so that you change the lock/unlock order of the mutexes. Experiment with the order of locks (and maybe extend the number of loop iterations) until you find a scenario where you can demonstrate deadlock. //Program: deadlockFree.c A simple threaded program to demonstrate the deadlock condition.Two threads are used to wait on two MUTEXES. Careful ordering of locks should...

  • _____ Which of the following is not a process found within the DBMS processes running in...

    _____ Which of the following is not a process found within the DBMS processes running in primary RAM? Listener Scheduler Executor Optimizer _____ For which of the following situation would you might consider the creation of an index on the attribute being used in order to enhance performance? Data sparsity on the attribute is high Attribute appears by itself in the search criteria Attribute being used in a join statement All of the above _____ Which of the following is...

  • I want to this question solution by programming c code. I need this solution as soon...

    I want to this question solution by programming c code. I need this solution as soon as possible i have to submit this code after 24 hours. please someone help this question thanks :D Programming Question: (15pts) Assume a finite number of resources of a single resource type must be managed. Processes may ask for a number of these resources and will return them once finished. If all resources are in use the request is denied and the process terminates....

  • Write a C program for: One technique for dealing with deadlock is called “detect and recover.” In...

    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...

  • This set of questions is involving multithreading in C++ and are multiple choice, choose the best...

    This set of questions is involving multithreading in C++ and are multiple choice, choose the best answer 1) Which action will not recover a process from deadlock? Terminate threads holding onto resources Terminate user process and restart Wait for the resource to be released by other threads None of the others 2) In a boss-worker thread model, the boss must keep in constant communication with the workers to make sure they are functioning correctly. True False 3) Process aging is?...

  • 1. True-false or multiple choice. Provide a one-sentence explanation you will get no credit for a correct answer without a proper explanation. Suggested time to spend on these questions: 10 minutes....

    1. True-false or multiple choice. Provide a one-sentence explanation you will get no credit for a correct answer without a proper explanation. Suggested time to spend on these questions: 10 minutes. [4x5-20ptsl (a) True or false: Peterson's algorithm for mutual exclusion offers bounded wait. b) Thue or falher Cumsider a concumcent program comitingof several 1oad indctioms e instructions (or instructions with similar effects as store). Such a program can never have any race conditions (c) True or false: Solutions based...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT