Sunteți pe pagina 1din 9

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, K.K.

BIRLA GOA CAMPUS


First Semester 2017-2018
Course Title : Operating Systems Course No : CS F372
Component : Comprehensive (Regular) Mode : Closed Book
Weightage : 40% Total pages: 4 Total Questions : 07 Max Marks : 120
Date : 12/12/2017 Time : 2:00 p.m. to 5:00 p.m. Duration : 3 hours

NAME: IDNO:
MARKS OBTAINED
RECHECK REQUEST: PART A PART B TOTAL

PART A
Question #1: Memory Management [15 Marks]
A. The system follows 3 level hierarchical paging. Time taken for accessing TLB is 2nS. Time
taken for accessing MM is 100nS. The page fault service time when the victim page is dirty
(which includes all the time from the page fault till restarting the same instruction) is 400nS. The
page fault service time when the victim page is not dirty (which includes all the time from the
page fault till restarting the same instruction) is 200nS. At any point assume that 30% of the
pages are dirty pages. Find time taken to access data
case a. when TLB miss but page tables and data are available in MM.
case b. when TLB miss, all page tables are available in MM but results in page fault.

2M case a.
2 + (3*100) + 100 = 402 ns
3M case b.
2 + (3*100) + (0.3*400 + 0.7*200) + case a. = 2 + 300 + 260 + 402 = 964 ns

B. A 64 bit system with Virtual Memory support has 42 bits address bus width. The system has
2 GB RAM with 16 KB frame size. The system follows hierarchical paging. One entry in inner
most page table is 8 bytes long and the entry size doubles in each level from inner most to outer
most.
a. Divide the logical address so that all page tables fit in frame boundary.
b. How many frames are required in MM, if you what to store the largest possible program and
all its page tables in the MM? (Mention frames required for each component)
c. If the process is of 16 GB size, how many frames are required in MM to hold program and
all its page tables in MM? (Mention frames required for each component)

2M a (5+7+8+9+10+11) + 14 = 64

4M b (1 + 25 + 212 + 220 + 229 + 239 ) + 250

4M c (1 + 1 + 1 + 1 + 1 + 29 ) + 220

Page 1
Question #2: Memory Management [15 Marks]
A. Consider the following definition of memory allocation strategies. Best fit: The allocator
places a process in the smallest block of unallocated memory in which it will fit. Good fit:
The allocator maintains the list of holes in increasing order of memory size and places a
process in the smallest block of unallocated memory in which it will fit. Suppose the OS
currently has a list of unallocated blocks (holes) of 6KB, 14KB, 19KB, 11KB, and 13KB
blocks. a. Find the appropriate block of memory for a 12KB process according to Best fit and
Good fit allocation strategies. b. Find the time complexity of both the algorithms if N are the
total number of holes.
Best fit Good fit
4M Block 13KB 13KB

4M Time complexity O(N) O(NlogN) + O(N)

B. Consider a process having eight virtual pages on disk is assigned a fixed allocation of four
page frames in main memory. Apply LRU page replacement policy for the following page
requests and calculate the number of page faults. Assume that the frames are initially empty.
1 0 2 2 1 7 6 7 0 1 2 0 3 0 4 5 1 5 2 4 5.

1 0 2 2 1 7 6 7 0 1 2 0 3 0 4 5 1 5 2 4 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4
7M - 0 0 0 0 0 6 6 6 6 2 2 2 2 2 5 5 5 5 5 5
- - 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 2 2 2
- - - - - 7 7 7 7 7 7 7 3 3 3 3 1 1 1 1 1
F F F F F F F F F F F F
12 page faults
Question #3: Deadlock [10 Marks]
Consider the following snapshot of the system of five processes P0 to P4 and four resources A, B,
C and D. At time t, the number of instances of resource A, B, C and D available are 1, 0, 2 and 0
respectively.
A. Determine the minimum value of W, X, Y and Z which will leave the system in safe state
B. Find the safe sequence.
Processes Allocated Maximum Claim
A B C D A B C D
P0 W 0 1 0 4 2 1 1
P1 2 1 Y 0 11 2 3 2
P2 1 X 1 0 4 2 1 0
P3 1 1 0 Z 1 1 1 1
P4 2 1 0 0 0 0 1 0

4M A W= 6 X= 1 Y= 4 Z= 0

6M B Safe sequence = <P4, P3, P2, P0, P1>

Page 2
NAME: IDNO:

Question # 4: Scheduling [20 Marks]


A. Find the static priority and base time quantum of the process with nice value 15.
B. Assume a system with 3 processes A, B and C. Processes A and B are under Group 1 and
Process C is under Group 2 with each group having weight of 0.5. The base priorities of
Processes A, B and C are 35, 32 and 37 respectively and the total execution time are 60, 120
and 90 time units respectively. If fair share scheduling decision making is in every 30 time
unit, find Normalized turnaround time of process A and Waiting period of process B.
C. Consider 4 processes A, B, C and D in a Uniprocessor system. xPy represents process P goes
for x units of I/O operation after every y units of execution. Following table shows arrival
time, execution time and xPy for all the processes. Scheduling policy is as follows: Assume
there are 3 queues Q0, Q1 and Q2 with priorities 0, 1 and 2 respectively. Q0 and Q1 follows
Round Robin with time quantum 1 and 2 respectively. Q2 follows FCFS. Process enters in Q0
initially and after completing I/O operation. If a process is preempted by a process in higher
priority queue, preempted process remains in the same queue at same position (i.e at head of
the queue) with remaining time quantum. If time quantum of a process expires, process is
moved to the next lower priority queue. Draw the schedule according to Multilevel
Feedback Scheduling Algorithm.

Process Arrival Time Execution Time xPy


A 0 7 5A3

B 2 9 2B5

C 4 6 CPU bound
D 8 8 1D4

Base time quantum = (140 – static


Static priority = Max_RT_Prio + Nice + 20 =
2M A priority) X 5 since static priority >=120
100 + 15 + 20 = 135
= (140 -135) X 5= 25 units
Normalized turnaround time of process A = 240/60 = Waiting period of process B = 270 -120
8M B
4 =150
10
M

Page 3
PART B

Q5. A barbershop consists of awaiting room with n chairs and a barber room with one barber
chair. If there are no customers to be served, the barber goes to sleep. If a customer enters the
barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy
but chairs are available, then the customer sits in one of the free chairs. If the barber is asleep, the
customer wakes up the barber. Consider this as an instance of the Producer-Consumer problem.
Identify the producer(s), the consumer(s) and the contents and maximum size of the bounded
queue. Write the pseudocode to coordinate the barber and the customers.

Solution: The producers of this problem are the customers. They produce work for the
consumer, the barber. The contents of the queue for the consumer are the consumers sitting in
the n chairs. The maximum size of the queue is n.

PSUEDOCODE: Initialize S to n.

Producer:

while(true) //keep the consumers coming


{
wait(S);
//get hair cut
}

Consumer:

while(true)
{
if(S < n)
{
//do haircut
signal(S);
}
}

Consider a typical disk that rotates at 15000 rotations per minute (RPM) and has a transfer rate
of 50 × 106 bytes/sec. If the average seek time of the disk is twice the average rotational delay
and the controller’s transfer time is 10 times the disk transfer time, the average time (in
milliseconds) to read or write a 512 byte sector of the disk is _____________. Explain your
answer. [12+8=20]

Solution:

• Disk latency = Seek Time + Rotation Time + Transfer Time + Controller Overhead

Page 4
• Seek Time: Depends no. tracks the arm moves and seek speed of disk
• Rotation Time: depends on rotational speed and how far the sector is from the head
• Transfer Time: depends on data rate (bandwidth) of disk (bit density) and the size of
request

• Disk latency = Seek Time + Rotation Time + Transfer Time + Controller Overhead
• Average Rotational Time = (0.5)/(15000 / 60) = 2 miliseconds [On average half rotation
is made]
• It is given that the average seek time is twice the average rotational delay So Avg. Seek
Time = 2 * 2 = 4 miliseconds.
• Transfer Time = 512 / (50 × 106 bytes/sec) = 10.24 microseconds

• Given that controller time is 10 times the average transfer time Controller Overhead = 10
* 10.24 microseconds = 0.1 miliseconds
• Disk latency
• = Seek Time + Rotation Time + Transfer Time + Controller Overhead
• = 4 + 2 + 10.24 * 10-3 + 0.1 miliseconds
• = 6.1 miliseconds

Q6. Given the following queue -- 95, 180, 34, 119, 11, 123, 62, 64 with the Read-write head
initially at the track
50 and the tail track being at 199. Give the time required to service the given requests using each of
the following algorithms.
(a) FCFS scheduling (b) SSTF scheduling (c) SCAN scheduling (d) C-SCAN scheduling, (f) C-LOOK
scheduling,

Solution:

Page 5
Page 6
Show how to implement the wait() and signal() semaphore operations in multiprocessor
environments using the TestAndSet() instruction. The solution should exhibit minimal busy
waiting. [10+10=20]

Page 7
Q7. Write a the pseudocode for a monitor that implements an alarm clock that enables a calling program
to delay itself for a specified number of time units (ticks). You may assume the existence of a real
hardware clock that invokes a procedure tick in your monitor at regular intervals.

Solution:
Monitor AlarmClock
{
condition self;
int delay;
void pause(int time)
{
delay = time;
self.wait();
}

void tick(int delta) //assuming delta is the amount of time that has passed
{
delay -= delta;
if(delay <= 0)
self.signal();

Page 8
}
}

Servers can be designed to limit the number of open connections. For example, a server may wish to have
only N socket connections at any point in time. As soon as N connections are made, the server will not
accept another incoming connection until an existing connection is released. Explain how semaphores can
be used by a server to limit the number of concurrent connections.

Solutions:

A semaphore is initialized to the number of allowable open socket connections.When a connection is


accepted, the acquire()method is called, when a connection is released, the release() method is called. If
the system reaches the number of allowable socket connections, subsequent calls to acquire() will block
until an existing connection is terminated and the release method is invoked.

Deadlock is defined as two or more processes are waiting indefinitely for an event that can be
caused by onlyone of the waiting processes. Give example of deadlock for 2 processes sharing
some common semaphore.

[10+5+5=20]

Solution:

Page 9

S-ar putea să vă placă și