Question

In: Other

1- Consider the following resource allocation graph and check whether it contains deadlock or not? Justify...

1- Consider the following resource allocation graph and check whether it contains deadlock or not? Justify your answer in detail.

R1 R3 P P2 (P3 , R2 R4

2- Consider the following page reference string:

4, 6, 7, 8, 6, 7, 8, 4, 6, 4, 4, 7, 5, 8

Assuming demand paging with three frames, how many page faults would occur for the following replacement algorithms? illustrate your work.

  1. FIFO replacement.
  2. LRU replacement.

3- What is swapping? explain the terms "swap in" and "swap out" with a neat diagram. Explain under which circumstances page faults occur and how they are resolved by the operating system.

Solutions

Expert Solution

Solution

Q1) The resource allocation graph contains a deadlock .

The reason for the deadlock is

Process P1 holding one instance of resource R2 requests for resource R1 held by process P2.

Process P2 holding resource R1 and one instance of resource R2 is requesting for resource R3 held by process P3.

Process P3 holding resource R3 is requesting resource R2 held by process P1 and P2.

Hence there is a cycle and there exists a deadlock as one process holding one resource is waiting for another resource held by another process which in turn is waiting for a resource held by another process (cycle goes on).

Q2)

FIFO : PAGE FAULTS =9

LRU : PAGE FAULTS = 9

Q3) Swapping is a memory management scheme in which any process can be temporarily swapped from main memory to secondary memory so that the main memory can be made available for other processes.

Swap in means to take the program from Hard disk and again bring them to the Main memory.

Swap out means to take the program from Main memory and to bring them in Hard disk.

#Occurance of page fault

A page fault occurs when the access to a page that has not been brought into main memory takes place. Verification is done by the operating system on the memory access, if found invalid aborts the program. If it is valid a free frame is located and I/O requested to read the needed page into the free frame.

#Handling of page faults by the OS

The kernel is traped by the computer hardware and program counter is saved on the stack.

CPU registers saves the current instruction state

To save the general registers and other volatile information an assembly program is started to keep the OS from destroying it.

Operating system finds the occurance of the page fault and tries to find out which virtual page is needed.

Operating system finds that a page fault has occurred and tries to find out which virtual page is needed.

Some times hardware register contains this required information. If not, the operating system must retrieve PC, fetch instruction and find out what it was doing when the fault occurred.

Once virtual address which caused page fault is known, system checks to see if address is valid and checks if there is no protection access problem.

If the virtual address is valid, the system checks to see if a page frame is free.

If no frames are free, the page replacement algorithm is run to remove a page.

If frame selected is dirty, page is scheduled for transfer to disk, context switch takes place, fault process is suspended and another process is made to run until disk transfer is completed.

As soon as page frame is clean, operating system looks up disk address where needed page is, schedules disk operation to bring it in.When disk interrupt indicates page has arrived, page tables are updated to reflect its position, and frame marked as being in normal state.

Faulting instruction is backed up to state it had when it began and PC is reset. Faulting is scheduled, operating system returns to routine that called it.

Assembly Routine reloads register and other state information, returns to user space to continue execution.


Related Solutions

Deadlocks. The Banker's algorithm is used for deadlock avoidance. Consider the state of resource availability and allocation defined by the following matrices.
Deadlocks. The Banker's algorithm is used for deadlock avoidance. Consider the state of resource availability and allocation defined by the following matrices.(1) Assuming that the total amounts for resources R1, R2, and R3 are 10, 2, and 10, should a new request to the Banker's algorithm by process P3 to acquire one additional resource from R1 and one additional resource from R3 be approved or denied? Explain why or why not(2) Assuming that the total amounts for resources R1, R2,...
Give an algorithm to detect whether a given undirected graph contains a cycle. If the graph...
Give an algorithm to detect whether a given undirected graph contains a cycle. If the graph contains a cycle, then your algorithm should output one. (It should not output all cycles in the graph, just one of them.) The running time of your algorithm should be O(m + n) for a graph with n nodes and m edges.
. Determine whether K4 (the complete graph on 4 vertices contains the following: i) A walk...
. Determine whether K4 (the complete graph on 4 vertices contains the following: i) A walk that is not a trail. ii) A trail that is not closed and is not a path. iii) A closed trail that is not a cycle.
From a theoretical macroeconomics perspective, consider whether the following statements are true, false, or uncertain. Justify...
From a theoretical macroeconomics perspective, consider whether the following statements are true, false, or uncertain. Justify your answers. An inflation target is necessary for good economic development. In a world where all countries would have fixed exchange rates, no country would have an effective monetary policy. In a devaluing country, borrowers who have borrowed in a foreign currency are more affected, than those who have borrowed in domestic currency. Technological development is impossible to measure.
Determine whether the following statement about graph theory is true or false. (1) If a graph...
Determine whether the following statement about graph theory is true or false. (1) If a graph with m vertices is connected, then there must be at least m-1 edges. (2) If a graph with m vertices has at least m−1 edges, then the graph must be connected. (3) A simple undirected graph must contain a cycle, if it has m vertices with at least m edges. (4) A graph must contain at least m edges, if it has m vertices...
1. Try running the deadlock simulator using the following command: java deadlock a 2 2 Explain...
1. Try running the deadlock simulator using the following command: java deadlock a 2 2 Explain why a deadlock does not occur. 2. There are two additional process command files ("b0.dat" and "b1.dat") in the distribution. Run the deadlock simulator with this command: java deadlock b 2 1 1 What happens? Now try this: java deadlock b 2 1 2 Why does the first command result in a deadlock but the second does not? Explain your answer in terms of...
Give a detailed example of a Resource-Allocation linear programming application model. Support whether the variables have...
Give a detailed example of a Resource-Allocation linear programming application model. Support whether the variables have to be integers for your example.
1. Consider an arithmetic expression of the form a#b=c. Check whether it is possible to replace...
1. Consider an arithmetic expression of the form a#b=c. Check whether it is possible to replace with one of the four signs: +, -, * or / to obtain a correct expression. Test Sample a b c Expected Output 1 2 3 5 True 2 8 2 4 True 3 8 3 2 False 4 6 3 3 True 5 5 2 0 False 6 10 2 2 False Make a MATLAB program
Find the area of the indicated region. We suggest you graph the curves to check whether...
Find the area of the indicated region. We suggest you graph the curves to check whether one is above the other or whether they cross, and that you use technology to check your answer. Between y = 2x^2 + 6x − 3 and y = −x^2 + 3x + 3 for x in [−2, 2]
C Programming Question: Q) Write a C - program to check whether a given graph is...
C Programming Question: Q) Write a C - program to check whether a given graph is Bipartite using Breadth-first search (adjacency list) Do take your time but please do post full code and also please do it in C.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT