How do you use the Banker’s Algorithm to detect deadlock? How do you use the Banker’s Algorithm to detect an unsafe state?
these data structures used in algorithm to detect
deadlock:
Available- A vector of length m indicates the number of available
resources of each type.
Allocation- An n*m matrix defines the number of resources of each
type currently allocated to a process. Column represents resource
and resource represent process.
Request- An n*m matrix indicates the current request of each
process. If request[i][j] equals k then process Pi is requesting k
more instances of resource type Rj.
We treat rows in the matrices Allocation and Request as vectors, we
refer them as Allocationi and Requesti.
Steps to detect deadlock:
Let Work and Finish be vectors of length m and n respectively.
Initialize Work= Available. For i=0, 1, …., n-1, if Requesti = 0,
then Finish[i] = true; otherwise, Finish[i]= false.
Find an index i such that both
a) Finish[i] == false
b) Requesti <= Work
If no such i exists go to step 4.
Work= Work+ Allocationi
Finish[i]= true
Go to Step 2.
If Finish[i]== false for some i, 0<=i<n, then the system is
in a deadlocked state.
Moreover, if Finish[i]==false the process Pi is deadlocked.
now, if a system is deadlocked then it is in unsafe state
How do you use the Banker’s Algorithm to detect deadlock? How do you use the Banker’s...
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) A process declaring its maximum need as maximum possible for each resource. In other words, if a resource A has 5 instances, then each process declares its maximum need as 5. (ii) A process declaring its minimum needs as maximum needs. For example, a process may need 2-5 instances of resource A. But it declares its maximum need as 2
Will a deadlock be possible? If yes. how to prevent the deadlock without change the nature of the problem Virtual Memory A computer system is in the Thrashing state: CPU utilization: 20% Virtual Memory swapping pages: 98% Other I/O: 5%. Which of the following will improve CPU utilization? Install Fast CPU. Increase virtual memory size. run more programs stop several programs that are running Install More RAM Install faster hard drive Add cache memory Increase page size Install larger hard...
Deadlocks and Banker’s Algorithm Is the following state safe? Is the following state safe? Suppose there are three processes. A, B, and C, and three resources, a CD-ROM, a printer, and a keyboard. Draw a resource allocation graph showing a deadlock involving all three processes. For each of the following cases, which deadlock-handling mechanism would you use and why? The computer is up for a very long time, the system runs a lot of batch jobs, and the processor is...
Code the Bankers' algorithm for deadlock avoidance as described in lecture. Apply this algorithm against the following data displaying the Work, Need and Allocation matrices for each pass of the algorithm provided a safe state exists. Process Allocation Max Available A B C D A B C D A B C D P0 0 0 1 2 0 0 1 2 1 5 2 0 P1 1 0 0 0 1 7 5 0 P2 1 3 5 4 ...
Question 2. Use the greedy algorithm to color the graph below, ordering the vertices alphabetically. Is this coloring optimal? How do you know? Question 2. Use the greedy algorithm to color the graph below, ordering the vertices alphabetically. Is this coloring optimal? How do you know?
Problem 1 (Bayes theorem and spam filters) Suppose you have develop a new algorithm to detect spam in an incoming email message. if the email is spam, there is a 98% chance your algorithm will detect it. On the other hand, if no spam is present, there is a 90% chance the algorithm will indicate that the message is not spam. Suppose that roughly 10% of all your email is spam. a) What is the probability a randomly chosen message...
Operating Systems Discuss real-life examples of deadlock, starvation, and race. Do not use computer science or computer system environment examples for this discussion forum. Also, do not use examples already stated in the book. Give at least ONE (1) example of each (that is, one example of deadlock, one starvation, and one race example). Be as specific as possible when explaining your answers.
Given the staircase example from the beginning of this chapter, identify the four necessary conditions for deadlock and explain whether each one is present, or is not present, in this case. Mutual exclusion: Resource holding: No preemption: Circular Wait: For the systems described below, given that all of the devices are of the same type, and using the definitions presented in the discussion of the Banker’s Algorithm, answer these questions: a. Calculate the number of available devices. b. Determine the...
Operating Systems Questions 1. What is the difference between a blocked state and a deadlock state? 2. How do you define the state of the operating system? 3. Differentiate between daemons and zombies. 4. What is the maximum number of process in a standard Linux installation? Why is the number of processes limited to this number? Can it be changed?
Java programming Exercise 32.11 Write a program that uses explicit locks (or semaphores) to cause a deadlock. Do not use the synchronized keyword. Repeatedly try to lock and unlock the locks and print messages to indicate when a lock is locked or unlocked to give some indication of what the program is doing. Using Thread.sleep) might be helpful to make a deadlock more likely. Exercise 32.11 Write a program that uses explicit locks (or semaphores) to cause a deadlock. Do...