OS Worksheet
OS Worksheet
iv) What is process scheduling and in what condition does it is needed? And
what is the main objective of process scheduling algorithms? Distinguish
between job scheduling (long term scheduler) and CPU scheduling (short
term scheduler).
A cycle?
Unsafe/safe state?
Deadlock?
And draw the corresponding wait-for graph for each.
R1 R2
R1 R2
P1 P2 P3
P1 P2 P3
R3 R4
R3 R4
Page 1 of 5
R1 R1 R1
P2 P2 P2
P1 P1 P1
R2 R2 R2
R1 P2 R2 R1 P2 R2 R1 P2 R2
P1 P3 P1 P3 P1 P3
R1 R2 R1 R2 R1 R2
P1 P2 P3 P1 P2 P3 P1 P2 P3
Page 2 of 5
vii) Based on the following information, answer the questions that follow:
Maximum
Allocated: Need:
Amount:
A B C A B C
P0 0 1 0 7 5 3
P1 2 0 0 3 2 2
P2 3 0 2 9 0 2
P3 2 1 1 2 2 2
P4 0 0 2 4 3 3
viii) Based on the following information of a system, answer the questions that
come next using the banker’s algorithm:
Processes:
Allocation: Maximum: 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 2 3 5 6
P3 0 6 3 2 0 6 5 2
P4 0 0 1 4 0 6 5 6
Page 3 of 5
Is the system in safe state?
What if the following resource requests are made?
o P1 requests (0, 4, 2, 0)
o P2 requests (1, 4, 3, 1)
o P3 requests (0, 4, 3, 1)
ix) A system has four processes and five allocate-able resources. The current
allocation and maximum needs are as follows:
Process 1 2 0 1 1 0 2 2 2 1 0
Process 2 1 1 0 1 0 2 1 3 1 0
Process 3 1 1 1 1 0 1 1 2 2 1
Page 4 of 5
xii) Define memory fragmentation and explain how internal and external memory
fragmentations are created.
xiii) What are the various Page Replacement Algorithms used for Page
Replacement? And when do the system uses them?
xiv) Explain the reason why API’s need to be used rather than direct system
call?
Page 5 of 5