You are on page 1of 22

Welcome to

CrackIT
OS numericals
Schedulers in OS-
FCFS Scheduling-

The process which arrives first in the ready queue is firstly assigned the CPU.
In case of a tie, process with smaller process id is executed first.
It is always non-preemptive in nature.
PROBLEM FCFS Example
SJF Scheduling Example
Round Robin Scheduling Example
Shortest Remaining Time First(SRTF)
Priority Scheduling Example
Page Replacement Algorithms

First In First Out (FIFO)

Consider page reference string 1, 3, 0, 3, 5, 6, 3 with 3 page frames.Find the number of page faults.
Optimal Page replacement
Consider the page references 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4 page frame. Find number of page
fault.
Least Recently Used
Consider the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4 page frames. Find number of
page faults.
Let the page fault service time be 10ms in a computer with average memory access time being 20ns. If
one page fault is generated for every 10^6 memory accesses, what is the effective access time for the
memory?
(A) 21ns
(B) 30ns
(C) 23ns
(D) 35ns
An application loads 100 libraries at startup. Loading each library requires exactly one disk access. The seek time
of the disk to a random location is given as 10ms. Rotational speed of disk is 6000rpm. If all 100 libraries are
loaded from random locations on the disk, how long does it take to load all libraries? (The time to transfer data
from the disk block once the head has been positioned at the start of the block may be neglected)
(A) 0.50s
(B) 1.50s
(C) 1.25s
(D) 1.00s
Consider the following table of arrival time and burst time for three processes P0, P1 and P2.

Answer:-

Process P0 is allocated processor at 0 ms as there is no other process in ready queue. P0 is preempted after 1 ms as
P1 arrives at 1 ms and burst time for P1 is less than remaining time of P0. P1 runs for 4ms. P2 arrived at 2 ms but P1
continued as burst time of P2 is longer than P1. After P1 completes, P0 is scheduled again as the remaining time for
P0 is less than the burst time of P2.

P0 waits for 4 ms, P1 waits for 0 ms amd P2 waits for 11 ms. So average waiting time is (0+4+11)/3 = 5.
A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded to begin with. The system
first accesses 100 distinct pages in some order and then accesses the same 100 pages but now in the reverse order.
How many page faults will occur?

(A) 196
(B) 192
(C) 197
(D) 195

Access to 100 pages will cause 100 page faults. When these pages are accessed in reverse order, the first four
accesses will node cause page fault. All other access to pages will cause page faults. So total number of page faults
will be 100 + 96.
Consider a disk system with 100 cylinders. The requests to access the cylinders occur in following sequence:
4, 34, 10, 7, 19, 73, 2, 15, 6, 20
Assuming that the head is currently at cylinder 50, what is the time taken to satisfy all requests if it takes
1ms to move from one cylinder to adjacent one and shortest seek time first policy is used?
(A) 95ms
(B) 119ms
(C) 233ms
(D) 276ms

4, 34, 10, 7, 19, 73, 2, 15, 6, 20


Since shortest seek time first policy is used, head will first move to 34. This move will cause 16*1 ms. After
34, head will move to 20 which will cause 14*1 ms. And so on. So cylinders are accessed in following order
34, 20, 19, 15, 10, 7, 6, 4, 2, 73 and total time will be (16 + 14 + 1 + 4 + 5 + 3 + 1 + 2 + 2 + 71)*1 = 119 ms.
An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm. Consider the
arrival times and execution times for the following processes:

You might also like