You are on page 1of 6

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI

Second Semester 2003-2004


Course Title : OPERATING SYSTEMS Course No CS C372 & IS C362
Component : Comprehensive Examination Open Book Component
Weightage : 30% Max Marks: 30 Date : 01-05-2004
Note: Attempt all the Questions. Start each answer from a fresh page.

Que #1 3 Marks
Disk requests come into the disk driver for cylinders 10,22,55,2,28,12,6,40 and 38
in that order. The disk drive has 60 cylinders numbered 0 to 59 and the current head
position is 26. A seek takes 6 millisecond / cylinder moved. How much seek time is
needed for
(A) FCFS (B) SSTF
(C) SCAN, (D) C – SCAN
(E) LOOK (F) C – LOOK

Answers

(A) Sequence (FCFS)


26  10  22  55  2  28  12  6  40  38

16+12+33+53+26+16+6+34+2 = 198

(B) Sequence (SSTF)


26  28  22  12  10  6  2  38  40  55

(C) Sequence (SCAN)


26  22  12  10  6  2  0  28  38  40  55
26  28  38  40  55  59  22  12  10  6  2

(D) Sequence (C – SCAN)


26  22  12  10  6  2  0  59  55  40  38  28
26  28  38  40  55  59  0  2  6  10  12  22

(E) Sequence (LOOK)


26  22  12  10  6  2  28  38  40  55
26  28  38  40  55  22  12  10  6  2

(F) Sequence (C – LOOK)


26  22  12  10  6  2  55  40  38  28
26  28  38  40  55  2  6  10  12  22
Que #2 3 Marks
Consider the organization of a UNIX file as represented by the inode. Assume that
there are 12 direct block pointers and a singly, doubly, and triply indirect pointer in
each node. Further, assume that the system block size and disk sector size are both
8K. If the disk block pointer is 32 bits, with 8 bits to identify the physical disk and
24 bits to identify the physical block, then
(A) What is the maximum file size supported by this system?
(B) What is the maximum file system partition supported by this system?
(C) Assuming no information other than that the file inode is already in main
memory, how many disk accesses are required to access the byte in
position 13,423,956.

Answer

a. Find the number of disk block pointers, which fit in one block by dividing the block
size by the pointer size:

8K/4 = 2K pointers per block

The maximum file size supported by the I-Node is thus:

12 + 2K + (2K  2K) + (2K  2K  2K)


Direct Indirect – 1 Indirect – 2 Indirect – 3
12 + 2K + 4M + 8G blocks

Which, when multiplied by the block size (8K), is

96KB + 16MB + 32GB + 64TB

Which is HUGE.
b. There are 24 bits for identifying blocks within a partition, so that leads to:

224  8K = 16M  8K = 128 GB

c. Using the information from (a), we see that the direct blocks only cover the first
96KB, while the first indirect block covers the next 16MB. the requested file
position is 13M and change, which clearly falls within the range of the first
indirect block. There will thus be two disk accesses. One for the first indirect
block, and one for the block containing the required data.

Que #3 4 Marks
A multilevel feedback queue algorithm works with the following condition
Number of queues 3 (Q1,Q2 and Q3)
Scheduling algorithm Q1  R R, Q2  preemptive priority
& Q3  FCFS
Method used to upgrade a process No upgrading among queues
Method to demote a process Q1After 2 units of time, Q2 When the Priority
becomes 0 (Priority of the process reduced by 1 for every 1 units of execution in CPU, if
2 processes have the same priority then the process came first to the queue), Q3The
Process who came first to the queue will get the first chance.
Method used to determine which queue a process will enter
P1, P3 are entering through Queue #2 (Q2)
P2 & P4 are entering through Queue #1 (Q1)

Process T.CPU burst CPU burst I/O burst Priority Arrival time
P1 14 7 6 6 0
P2 13 8 1 5 1
P3 10 4 3 4 4
P4 13 8 4 4 6
Calculate Average waiting time, average turn around time, and CPU utilization

P1 P2 P2 P1 P2 P2 P4 P4 P1 P3 P4 P4 P1
P2 P3 P3 P1 P2 P4 P4 P1 P2 P3* P4 P4* P1*
P3 P3 P3 P4 P4 P4 P1 P1 P1 P1 P4 P4** P1
P1 P3** P2* P1** P2 P2 P2 P2 P3 P3*** P2**

CPU utilization 100%


Average waiting time (23 + 35 + 29 + 15) / 4  25.5
Average Turn around time (43 + 49 + 45 + 32) / 4  42.25

Que #4 4 Marks
Consider the following test program for an implementation of join. When parent
thread calls join on a child thread the parent does the following
1. If the child is still running the parent blocks until the child finishes
2. If the child has finished the parent continues to execute without blocking.

int x=10;
pthread_t tid[25];

void main()
{ void *fun1(void *a)
int i,j=0; {
for(i=0;i<3;i++) { x = x /2 ;
if(fork()) { x=x – 3;
x=x + 5; x=x*3;
pthread_setPriority(tid[I],x); }
pthread_create(tid[i],NULL,fun1,0);
x = x+10;
}
else { void *fun2(void *a)
x = x – 5; {
pthread_setPriority(tid[I],x); x = x /4 ;
x=x + 2;
pthread_create(tid[i],NULL,fun2,1); x=x*3;
x=x - 20; }
}
x=x + 10;
}
for(i=0;i<3;i++) {
pthread_join(tid[i]);
}
printf(“%d\n”,x);
}

Assume that the scheduler run threads in non-preemptive Priority scheduling (the
more the priority number the higher the priority is). Main thread is having the priority
value 5.What will be the values of x (all copies of x) after execution?

Answer

P1 237
P2 63
P3 48
P4 39
P5 3
P6 9
P7 9
P8 -18

Que #5 4 Marks
Consider the following page reference string
2,3,1,2,4,5,1,2,3,4,5,2,6,2,1,2,3,1,4,5,6
How many page faults would occur for the following page fault algorithms,
assuming 3 and 4 available frames. In the beginning the frames are empty.
(A) Optimal replacement
(B) LRU replacement
(C) FIFO replacement
(D) Second chance replacement

Answer

(A) Optimal 12 and 9


(B) LRU 17 and 14
(C) FIFO 16 and 11
(D) Second Chance 17 and 14
Que #6 3 Marks
Suppose we have a computer system with 44-bit virtual address, page size of 64K,
and 8 bytes per page table entry
(A) How many pages are in the virtual address space?
(B) Suppose we use 3 level paging and arrange for all inner page tables to fit
in exactly to a single page frame. How will the bits of the address be
divided up?
(C) Suppose we have a 4GB program such that the entire program and all
necessary page tables (using 3 level pages from above) are in memory.
How much memory, in Page frames, is used by the program, including its
page table?

Answer
(A) 2 ^ 44 / 2 ^ 16 = 2 ^ 28
(B) 2,13,13,16
(C) 2 ^ 16 + 3
Que #7 2 Marks

A computer with 32-bit address uses 3 level page tables. Virtual addresses are
split into 3-bit outer and 9 bit and 9 bit inner levels and an offset (inner page table are
designed to fit exactly in one frame).
(A) How large the pages are?
(B) How many are there in the address space?
(C) How long is one entry in page table?

Answers
(A) 2K
(B) 2 ^ 32 / 2 ^ 11 = 2 ^ 21
(C) 4 byte
Que #8 4 Marks

Implement Reader – Writer problem with writer dominance using


(A) Critical region
(B) Monitor

Answer

Main points to be noticed

Implementation of Reader and writer


If n readers are executing CS then 1 writer came after that n+1 th reader
came. The n+1 th reader must get chance only after n readers and 1 writer completes its
critical section.
Que #9 1 Marks
Why is the name of a file usually not stored in the file descriptor?

Because storing the name in the file descriptor would not allow links — two different
directories referring to the same file, but by different names.

Que #10 2 Marks


A system has three processes (P1,P2,P3) and three resources (R1,R2,R3). There
are two instances of R1 and R2 and one instance of R3. P1 holds a R1 and is requesting a
R2. P2 holds a R1 and a R2 is requesting an R3. P3 holds a R2 and R3 and is requesting a
R1. Draw the resource allocation graph for this situation. Does the deadlock situation
exist? Prove your answer.

There exist a deadlock (0.5 marks)


Prove it by using banker’s algorithm (1.5 Marks)

You might also like