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);
}
}
In the code below, three processes are competing for six resources labeled A to F. a....
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 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, 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 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 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...
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 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...
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...
I have done the a and b, but i'm so confuse with other questions, could someone help me to fix these questions, thanks so much. 4 Directed graphs Directed graphs are sometimes used operating systems when trying to avoid deadlock, which is a condition when several processes are waiting for a resource to become available, but this wil never happen because Page 2 p2 T2 Figure 1: Minimal example of a resource allocation graph with deadlock other processes are holding...
i. In the space provided, write appropriate data structure for following applications: a. An operating system is to process requests for computer resources by allocating the resource in the order in which they are requested b. A word processor to have f key that causes the preceding command to be redisplayed. Every time the user presses f key, the program shows the command that preceded the one currently displayed C. dictionary of words used by a spelling checker to be...