Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Operating System Questions 1) Process P0 requires a resource held by process P1

ID: 3861160 • Letter: O

Question

Operating System Questions

1) Process P0 requires a resource held by process P1 while P1 requires a resource held by P0. When does this scenario imply a deadlocked state?

2) Consider a system consisting of four instances of a resource type that are shared by three processes. Each process requires at most two instances of the resource. Show that deadlocks cannot occur in this system. Hint: There will never be circular waiting.

3) Consider the following snapshot of a system. Determine if the system is in a deadlocked state.

How is a page fault detected?

Allocation Request Available Poll 0 1 011 0 101120 2 0 Ps 0 0 1 DI bl-C0 VB 2 Al D00211 st c 10210 RB 01230 A10-22 D00210 ion 1020 IO C 10201 ll-B 0 0 1 10 A-1100 01234

Explanation / Answer

1) Process P0 requires a resource held by process P1 while P1 requires a resource held by P0. This scenario imply a deadlocked state when there are 2 instances of resource only and no process is able to complete its execution without the second instance of resource.

2) A system consisting of four instances of a resource type that are shared by three processes. Each process requires at most two instances of the resource.

Available instance of resource = 1

process P0 is allocated one intance of resource . It can be given another instance . So it completes its execution .

After execution it deallocate 2 instances of resource.

Available instance of resource = 2.

Now P1 can be allocated another resource and after execution it deallocate 2 instance

Available instance of resource = 3.

and so on . So all processes can complete their execution and there will not be any deadlock.

3)

Need matrix

As P0 need matrix is 0 for all resources , it can execute , so add it in safe sequence.

Available = Available + Allocation(P0) = <1 2 0 1> + <1 0 1 0> = <2 2 1 1>

P1 need matrix = <0 1 0 0>   <   < 2 2 1 1 >(Available ) so add it into safe sequence. After execution of P1 , it dellocates resources .

Available = <2 2 11> + <1 0 0 0> (Allocation(P1))

Available = <3 2 1 1>

P2 need< Available , So it can exeute safely

Available = <3 2 1 1> + < 1 1 2 2> = <4 3 3 3>

P3 need < Available , So it can execute safely

Available = < 4 3 3 3> + <0 1 0 1> = <4 4 3 4>

P4 need < Available , So it can execute safely

Available = < 4 4 3 4> + <0 0 1 0> = < 4 4 4 4>

So <P0,P1,P2,P3,P4,P5> is safe sequence.

The page fault is detected using the present bit in the page table

Process Need = Request-Allocation P0 <0 0 0 0> P1 <0 1 0 0> P2 <0 1 0 0> P3 <2 2 1 0> P4 <2 0 0 1>