0% found this document useful (0 votes)
11 views

Test-5-CS - Operating System - Basic PDF

Made easy test series for Gate CSE

Uploaded by

PALLAVI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Test-5-CS - Operating System - Basic PDF

Made easy test series for Gate CSE

Uploaded by

PALLAVI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

SY

Corporate Office (Delhi): 44-A/1 Kalu Sarai (Sarvapriya Vihar), New Delhi-16, Ph: 011-45124612, 9958995830
Visit us at: www.madeeasy.in | E-mail us at: [email protected]

Delhi | Hyderabad | Noida | Bhopal | Jaipur | Lucknow | Indore | Pune | Bhubaneswar | Kolkata | Patna
EA
Lockdown Period
Open Practice Test Series
(Also useful for ther Exams)
E

CS & IT : COMPUTER SCIENCE & IT


AD

TEST No. -05 | OPERATING SYSTEM

Read the following instructions carefully


1. This question paper contains 33 MCQ’s & NAQ’s. Bifurcation of the questions are given below:
M

17 to 28

29 to 33

2. Choose the closest numerical answer among the choices given.


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Multiple Choice Questions : Q.1 to Q.10 carry 1 mark each

Q.1 Consider the following statements:


(a) Round-Robin scheduling policy is most suitable for a time shared operating system.
(b) A multi-user, multiprocessing operating system can not be implemented on hardware that does not
support atleast 2 modes of CPU execution.
(c) Interrupt from CPU temperature sensor will be handled at a higher priority than interrrupt from hard
disk by computer.
(d) While switching context from process A to process B, operating system does not change the address
translation table.
Which of the above statement is false?

1. (d)

SY
(a) Round robin works on time quantum, after certain period of time every process gets the CPU unit for
its completion, hence it’s most suitable.
(b) Since OS is multiuser and multiprocessing, hence security is the primary concern so that user processes
and Kernel processes can be isolated.
Hence two modes are required.
(c) When CPU temperature is too high, the BIOS initiate an interrupt. OS given top priority to this interrupt.

Q.2 Consider the following statements


EA
(d) Address translation table need to be changed when switching context from process A to process B.

1. System calls are needed to set up shared memory between two processes.
2. A privileged instruction is needed to change the mode from privileged to non-privileged mode.
3. An ISR is invoked on completion of I/O in asynchronous I/O but not in synchronous I/O.
4. The return code for the fork system call is zero for the new process, whereas the non-zero process
identifier of the child is returned to the parent.
E

Which of the above statements are correct?


(a) 1 and 3 (b) 3 and 4
(c) 2 and 3 (d) 1 and 4
AD

2. (d)
1. Since, each process has its own address space, it needs to involve the Kernel when dealing with other
process address space.
2. A software interrupt is required to switch between the two modes.
3. In both synchronous and asynchronous I/O an ISR is invoked after completion of the I/O.
M

4. Statement is correct.

2 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.3 Consider the following statements with respect to thread of the same process
S1 : To switch between two user-level threads, context switch is not required.
S2 : Light weight context switching is required to switch between two Kernel-level threads.
S3 : User-level threads of a particular process are scheduled to run within that process’s time slice.
S4 : Kernel level threads can not share the code segment.
Which of the above statements are true?
(a) S2 and S4 (b) S1 and S3
(c) S3 and S4 (d) S1, S2 and S3

3. (d)
• Switching between two user level threads only require procedure calls not context switching.
• All Kernal threads operations are implemented in Kernal, and OS schedules all threads in the system.
• Since user level threads are transport to Kernal, hence are not scheduled independently and hence

SY
are not given independent time slice.
• Threads do share the code segment.

Q.4 Consider the methods used by process P1 and P2 for accessing their critical sections whenever needed,
as given below. The initial values of shared Boolean variables, S1 and S2 are random assigned.
Method used by P1 Method used by P2
do
{
EA
flag[i] = True;
do
{
flag[j ] = True;
S1 = S2 S1 = S2+1;
while (P); while (Q);
critical section critical section
flag[i] = False; flag[j ] = False;
Remainder section Remainder section
} while(1); } while(1);
E
For the program to guarantee mutual exclusion, the predicate P and Q in the while loop should be
(a) P : Flag [j ] = true and S1! = S2 (b) P : Flag [j ] = true and S1 == S2
Q : Flag [i] = true and S1 == S2 Q : Flag [i] = true and S1! = S2
AD

(c) P : Flag [i] = true and S1! = S2 (d) P : Flag [i] = true and S1 == S2
Q : Flag [j ] = true and S1 == S2 Q : Flag [j ] = true and S1! = S2

4. (b)
To enter the critical section, process Pi first sets flag [i] to be true set S1 = S2, thereby asserting that if the
other process wishes to enter the critical section it can do so. If both processes try to enter at the same
time. The S1 will be set S2 or S2 +1 at roughly the same time. Only, one of these assignment will last; the
M

other will occur, but will be overwritten immediately.

Q.5 Assume a page reference string for a process with 3 frames (initially all are empty). The page reference
string has length 52 with 4 distinct page number occurring in it. For any page replacement algorithm, what
is a lower bound and upper bound on the number of page faults?
(a) 2, 26 (b) 3, 4
(c) 4, 26 (d) 4, 52

5. (d)
Since 4 distinct page numbers are only to be accessed. Hence the best condition i.e., the condition with
minimum number of page faults will be accessing all those elements repeatedly that are in the frame
already, which will give maximum 4 page faults.
If, considered the worst case, it will be on every iteration, we are accessing the same element that has
been removed from the frame, which will give 52 page faults.

3 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.6 A single processor system has five resource types A, B, C, D and E which are shared by four processes.
The current allocation and maximum needs are as follows:
Allocated Maximum Available
Process
A B C D E A B C D E A B C D E
P0 1 0 2 1 1 1 1 2 1 3 0 0 1 2 3
P1 2 0 1 1 0 2 2 2 1 0
P2 1 1 0 1 0 2 1 3 1 0
P3 1 1 1 1 0 1 1 2 2 1

Which of these processes will finish LAST?


(a) P0 (b) P1
(c) P2 (d) None because system is in deadlock

6. (b)

SY
Calculating the need matrix
A B C D E
P0 0 1 0 0 2
P1 0 2 1 0 0
P2 1 0 3 0 0
P3 0 0 1 1 1

Since, available = 00123, hence only P3 can be satisfied.


EA
Remaining = (00123) – (00111) = (00012) + (11221) = (11233)
Now P0 can be executed,
Remaining = (11233) – (01002) = (10231) + (11213) = (21444)
Now P2 can be executed,
Remaining = (21444) – (10300) = (11144) + (21310) = (32454)
Now P1 can be executed.
E
Q.7 Consider a scenario, having fixed partition allocation scheme where each partition is of size 100 kB,
500 kB, 200 kB, 300 kB and 600 kB. In these partitions, the processes that are needed to be placed are
212 kB, 417 kB, 112 kB and 426 kB (in order). How many partitions will remain unallocatted after placing
AD

the processes in each of first fit, best fit and worst fit algorithm respectively. Also, which policy(s) will be
successful in placing all these processes.
(a) 4, 1, 2 ; Best fit and First fit (b) 2, 1, 2 ; Best fit
(c) 4, 2, 3 ; Best fit (d) 3, 2, 3 ; Best fit and First fit

7. (b)
M

100 kB 100 kB 100 kB

212 kB 417 kB 417 kB


500 kB 500 kB 500 kB
188 kB 83 kB 83 kB
112 kB 112 kB
200 kB 200 kB 200 kB
88 kB 88 B
212 kB 112 kB
300 kB 300 kB 300 kB
88 kB 188 kB

417 kB 426 kB 212 kB


600 kB 600 kB 600 kB
183 kB 174 kB 388 kB

First fit Best fit Worst fit


Unallocated partition = 2 Unallocated partition = 1 Unallocated partition = 2
{1 process left for placed} {all process placed} {1 process left for placed}

4 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.8 Consider the virtual page reference string:


1, 2, 3, 2, 3, 4, 1, 4, 2, 3, 2, 1, 4, 2, 3, 1
on a demand paged virtual memory system running on computer system that has main memory size of 3
page frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number of page faults
under the corresponding page replacement policy. Then
(a) OPTIMAL < LRU < FIFO (b) OPTIMAL < FIFO < LRU
(c) OPTIMAL = LRU (d) OPTIMAL = FIFO

8. (b)

LRU : 1 2 3 2 3 4 1 4 2 3 2 1 4 2 3 1

3 3 3 2 2 2 2 2 2
2

SY
2 H H 2 1 H 1 3 H 3 4 H 4 1

1 1 1 4 4 4 4 1 1 3 3

Total page faults = 11

FIFO : 1 2 3 2 3 EA 4 1 4 2 3 2 1 4 2 3 1

3 3 3 2 2 2 1
2
2 H H 2 1 H 1 1 H H 4 H H 4

1 1 1 4 4 4 3 3 3

Total page faults = 9

Optimal : 1 2 3 2 3 4 1 4 2 3 2 1 4 2 3 1
E

3 4 3 3 3

2 2 H H 2 H H H 2 H H 2 H H 1
AD

1 1 1 1 1 4 4

Total page faults = 7

Q.9 Consider the following statements:


1. Loop instructions cannot be interrupted till they complete.
2. Nearest cylinder next disk scheduling strategy gives the best throughput in comparison to first come
M

first serve scheduling strategy.


3. Using large file block size in a fixed block size file system leads to poor disk throughput.
Which of the above statements are false?
(a) Only 1 (b) Only 1, 2 and 3
(c) Only 1 and 3 (d) Only 2

9. (c)
1. CPU senses interrupt request line after every instruction.
2. Nearest cylinder next disk scheduling strategy gives the best throughput but the only problem is it
can lead to starvation.
3. Using large file block size in a fixed block size file system leads to better disk throughput but poor
disk space utilization.

5 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.10 Consider the following statements:


1. Contiguous allocation of disk space can lead to external fragmentation.
2. Under linked allocation of disk space, if a program has just read the tenth disk block, now if it want to
read the sixth disk block, it will again start accessing from the first disk block.
3. Indexed allocation can not lead to external fragmentation.
Which of the above statements is/are correct?
(a) Only 1 and 2 (b) Only 2 and 3
(c) All of these (d) None of these

10. (c)
1. As files are allocated and deleted, the free disk space is broken into little pieces, hence can lead to
external fragmentation.
2. Linked-allocation can be used effectively only for sequential access file. To find the ith block of a file.

SY
We must start at the beginning of that file and follow the pointers until we get the ith block.
3. Statement is correct.

Numerical Data Type Questions : Q. 11 to Q. 16 carry 1 mark each

Q.11 Consider a uniprocessor system which has to execute an infinite sequence of processes which arrive
EA
periodically at the rate of 6 processes per minute and each process requires an average of 9 seconds of
service time. The fraction of time CPU busy is _________ (in sec).

11. (0.9)
The processes are arriving at a period of 6 processes per minute.
So, the arrival rate = 1 processes in every 10 seconds
Service time = 9 sec.

9
= 0.9sec
E
Time for which CPU is busy =
10

Q.12 Jobs A, B, C, D and E with running time of 13, 10, 5, 9 and 1 respectively arrive at computer in the time
AD

order 0, 5, 7, 10, 12. If the priority of these jobs is in the order C, B, E, A and D and the policy used for
scheduling is that a higher priority job always succeeds in preempting. Context switching takes 1 unit of
time. The exact number of context switches needed are _______. (Do not count the context switches at
time 0 and at the end).

12. (6)
Process At Bt Priority
M

A 0 13 4
B 5 10 2
C 7 5 1
D 10 9 5
E 12 1 3

Preparing the Gantt Chart,


A B C B E A D
0 5 7 12 20 21 29 38

C B E A D
So, there are total 6 number of context switches.

6 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.13 Suppose 10 processes P1 to P10 share 7 identical resource units which can be reserved and release 1 at
are time the maximum resource requirement of a processs Pi is SP where SP is greater then 0. The maximum

⎛ 10 ⎞
value of Si ⎜ ∑ S P ⎟ that ensures deadlock does not occurs is ________ .
⎝ i =1 ⎠

13. (16)
In order to ensure a deadlock free system,
Sum of resource needs < [Number of resources + Number of processes] < [7 + 10] < 17
Maximum value that can be used is 16.

Q.14 A demand paging system has page fault service time as 125 time units if page is not dirty and 400 times
units of page fault service time if it is a dirty page. Memory access time is 10 time units. The probability

SY
of a page fault is 0.3. In case of page fault, the probability of page being dirty is P. It is observed that
average access time is 50 time units. Then, the value of P is ______? [upto four decimal places]

14. (0.0667)
50 = 0.3 (P ∗ 400 + (1 – P) ∗ 125) + 0.7 ∗ 10
⇒ 50 = 0.3(400 P + 125 – 125 P) + 7



43
43
43 – 37.5
=
=
=
EA
0.3 (275 P + 125)
82.5 P + 37.5
82.5 P
⇒ 5.5 = 82.5 P
5.5
⇒ P = = 0.0667
82.5

Q.15 A CPU generates 64 bits virtual address. Page size is of 8 KB. The processor has a translation-look a
E

side-Buffer (TLB) which can hold a total of 256 page table entries and is 4-way set associative. The
minimum size of TLB tag is __________ bits.
AD

15. (45)
Page Size = 8K
Offset bits = 13
Virtual Address = 64 bits
Remaining bits = 64 – 13 = 51 bits

256
Number of sets = = 64 = 6 bits
M

4
Tag bits = 51 – 6 = 45 bits

7 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.16 A file system with 512 GB disk uses a file descriptor with 16 direct block addresses, 1 indirect block
address, 1 doubly indirectly block address and 1 triple indirect block addresses. Size of each disk block
is 256 bytes and the size of each disk block address is 8 bytes. The maximum possible file size is
__________ (in MB).

16. (8)
Direct block addressing = 16 ∗ 256 ⇒ 4 KB
⎡ 256 ⎤
Single indirect block addressing = ⎢ ⎥ ∗ 256B
⎣ 8 ⎦
= 25 ∗ 28 B
= 213 B ⇒ 8 KB
2
⎡ 256 ⎤

SY
1 doubly indirect block addressing ⇒ ⎢ ⎥ ∗ 256 B
⎣ 8 ⎦
⇒ (25)2 ∗ 28 B
⇒ 210 ∗ 28 B
⇒ 256 KB
3
⎡ 256 ⎤
1 triple indirect block addressing ⇒ ⎢ ⎥ ∗ 256 B

⇒ (25)3 ∗ 28 B
EA⎣ 8 ⎦

⇒ 215 ∗ 28 B
⇒ 223 B
⇒ 8 MB
E
AD
M

8 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Multiple Choice Questions : Q.17 to Q.28 carry 2 marks each

Q.17 Assume 2 processes computer ( ) and science ( ) that are concurrent and that the three semaphore mutex,
Q and R initialized to 1 are shared between the two processes. Q is a semaphore on file 1 and R on file 2.
Computer ( ) Science ( )
{ {
P(mutex); P(Q);
P(Q); /*read from file1*/
/*write to file1 */ P(R);
P(R); /*write to file2*/
/*write to file2*/ V(Q);
V(Q); V(R);
V(mutex); P(mutex);

SY
/*do something P(Q);
P(Q); /*write to file1 */
/*read fro file1 */ V(Q);
/*write to file2 */ V(mutex);
V(R);
V(Q);
}
EA
Which of the following holds by above process?
(a) Deadlock and no starvation (b) No deadlock but starvation
(c) Both deadlock and starvation (d) No deadlock or starvation

17. (c)
1. Computer ( ) → p (mutex) → mutex = 0
p (Q) → Q = 0
E

2. Science ( ) → p (Q) → process sleep


3. Computer ( ) → p (R) → R = 0
v(Q) → Q = 1, science ( ) awake
AD

4. Science → p(Q); Q = 0; p(R) → process sleep


5. Computer → v(mutex) → mutex = 1
p(Q) → process sleep
Hence a deadlock.
M

9 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.18 A system has five processes and four allocatable resources. The current allocation and maximum needs
are as follows:
Allocated Maximum Available
Process
X Y Z W X Y Z W X Y Z W
P0 1 0 2 0 3 2 4 2 a 0 0 b
P1 0 3 1 2 3 5 1 2
P2 2 4 5 1 2 7 7 5
P3 3 0 0 6 5 5 0 8
P4 4 2 1 3 6 2 1 4

What is the smallest value of a, b for which the system is in a safe state?
(a) a = 2, b = 2 (b) a = 4, b = 5
(c) a = 3, b = 4 (d) a = 2, b = 1

SY
18. (d)
X Y Z W
P0 2 2 2 2
P1 3 2 0 0
P2 0 3 2 4
P3 2 5 0 2
P4 2 0 0 1
EA
Since available is a 0 0 b, let’s suppose a takes value 2 and b takes the value 1.
Available = 2 0 0 1
P4 → Complete → Avail = (0000 + 6214) = 6214
P1 → Complete → Avail = (6214) – (3200) = (3014) + (3512) = (6526)
P0 → Complete → Avail = (6526) – (2222) = (4304) + (3242) = (7546)
P2 → Complete → Avail = (7546) – (0324) = (7222) + (2775) = (9, 9, 9, 7)
P3 → Complete → Avail = (9997) – (2502) = 7495
E

Hence, the system is in a safe state will value of a as 2 and value of b as 1.

Q.19 Consider the following statements w.r.t. deadlock,


1. An OS implements a policy that requires a process to release all resources before making a request
AD

for another resource can lead to starvation but not deadlock.


2. In deadlock prevention, the request for resource is always guaranteed if the resulting state is safe.
3. Deadlock can be prevented, if the resources are numbered uniquely, and processes are allowed to
request for resources only in decreasing resource number.
4. Deadlock avoidance has less restrictions than deadlock prevention.
Which of the above statement is/are false?
M

(a) Only 1 and 2 (b) Only 1 and 3


(c) Only 3 and 4 (d) Only 2

19. (d)
1. The policy is a deadlock prevention policy, but can lead to starvation.
2. In deadlock prevention, one of the four condition for deadlock must not be satisfied. So, state even
being safe can’t led to successful request.
3. It will help in violating circular wait condition for deadlock.
4. Under deadlock avoidance, just the safe state need to be checked and hence is less restrictive
deadlock prevention scheme.

10 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.20 Consider the following statements:


S1 : The total size of address space in a virtual memory system is limited by the available main memory.
S2 : The best fit techniques for memory allocation ensures the memory will never be fragmented.
S3 : Locality of reference implies that the page reference being made by a process will always be the page
that is being used in the previous page reference.
S4 : Virtual memory reduces the context switching overhead.
How many of the above statements are false?
(a) Only S1 and S2 (b) Only S1 and S3
(c) Only S1, S2 and S3 (d) S1, S2, S3 and S4

20. (d)
• The total size of address space in a virtual memory system is limited by the available secondary
storage.

SY
• Best fit technique can also suffer from fragmentation.
• Locality of reference implies that the page reference being made by a process is likely to be the page
used in the previous page reference.
• In a system with virtual memory context switch includes extra overhead in switching of address
space.

Q.21 Consider a disk system with 200 cylinders. {0-199} the requests to access the cylinders occur in the
EA
following sequence: 3, 33, 9, 6, 18, 72, 1, 14, 5, 19.
Assuming that the head is currently at cylinder 50, and it takes 1 ms to move from one cylinder to adjacent
one. What will be the seek time using FCFS policy ?
(a) 120 ms (b) 122 ms
(c) 276 ms (d) 200 ms

21. (c)
• FCFS
E

0 1 3 5 6 9 14 18 19 33 50 72 199
47
30
3 24
AD

54
71 12
13
8
14

Total time = 47+30+27+12+54+71+13+8+14 = 276 msec


M

11 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.22 A certain hard disk rotates at 6000 rpm. It has 1 KB per sector and average 64 sectors/track and has a
seek time of 5 msec.
Which of the following statements is/are true?
S1 : The data transfer rate of the drive is 6400 KBPs.
S2 : The time required to read 800 random sectors is 4.13 sec.
S3 : The time required to read 800 successive sectors is 0.0052 sec.
(a) Only S1 and S2 (b) Only S2 and S3
(c) Only S2 (d) Only S1

22. (d)
• Rotational latency ⇒ 6000 rotation → 60 sec
1 rotation ⇒ 1/100 sec

SY
1 1 1
Rotational latency ⇒ × = sec = 0.005sec
2 100 200
1
Transfer time = 64 KB ⇒ sec
100
1
1 KB ⇒ sec = 0.000156 sec
6400

Data transfer rate ⇒


1
EA
100
sec → 64 KB

1 sec → 64 KB × 100
→ 6400 KBPs
• Time required to read 800 random sectors
Total time required = [Seek time + RL + TT (1 sector)] × 800
= (0.005 + 0.005 + 0.000156) × 800
E

= 8.12 sec
• Total time = Seek time + Rotational latency + Transfer time
= 5 msec + 0.005 sec + 0.1248 sec
AD

= 134.8 msec
M

12 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.23 In a computer system, three files of size 11052 B, 4992 B and 5172 B need to be stored. For storing these
files on disk, we can use either 100 B disk block or 200 B disk block. For each block used to store a file,
2 bytes of book keeping information also needs to be stored on the disk. Thus, the total space used to
store a file is the sum of space taken to store the file and space taken to store the book keeping information
for the blocks allocated for storing the file. A disk block can store either book keeping information for a file
or data from a file, but not both. What is the total space required for storing the files using 100 B and 200
B disk blocks respectively.
(a) 21800 B, 22240 B (b) 21700 B, 22000 B
(c) 21900 B, 22000 B (d) 21800 B, 22200 B

23. (c)
100 B
100 B Bytes needed Block for

SY
File size for Book keeping
block Information
4992 50 100 1
5172 52 104 2
11052 111 222 3
Total 213 6
Space = 213 × 100 + 6 × 100 = 21300 + 600 = 21900 B

200 B

File size

4992
EA
200 B
block
25
Bytes needed
for Book keeping
50
Block for
Information
1
5172 26 52 1
11052 56 112 1
Total 107 3
Space = 107 × 200 + 3 × 200 = 22000 B
E
AD
M

13 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.24 Suppose that you wish to design a virtual memory system with the following characteristics:
• Size of page table entry is 4 bytes.
• Each page table must fit into a single page frame.
• System must be able to support virtual address space of 4 GB.
You decided to use a multi-level paging scheme with no more than 2 levels of page tables. What is the
minimum page size that the system must have? (Assume last level page table must be fit into single
page frame)
(a) 210 B (b) 211 B
(c) 212 B (d) 213 B

24. (c)
Let 2P be the page size.
Since page table entries are 4 bytes in size.

SY
1st Page table size = Page table entry × Page table entry size

232 2
= ×2
P
= 234 – P
2nd Page table size = Page table entry × PTE size

=
EA
234 −P
× 22
2P
= 236 – P – P
Last level page table must be fit into page size
So,
2P = 236 – P – P
E

P = 36 – P – P
3 P = 36
P = 12
AD

So page size will be 212 bytes.

Q.25 Consider the following statements:


1. Paging suffers from internal fragmentation and segmentation suffers from external fragmentation.
2. FIFO replacement policy ignores locality of reference.
3. The essential content(s) in each entry of page table are both virtual page number and page frame
number.
M

4. There is no problem to use single level page table even if it is large size, because there is no overhead,
to maintain large page table.
Which of the above statements are correct?
(a) Only 3 and 4 (b) Only 2 and 3
(c) Only 1 and 4 (d) Only 1 and 2

25. (d)
1. Statement is correct.
2. A page which was referenced last may also get replaced; although there is high possibility that the
same page may be needed again since it ignores locality of reference.
3. The essential content in each entry of a page table are page frame number.
4. It is not feasible because of the large memory overhead in maintaining the page tables.

14 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.26 Consider the following atomic operation compare-and-swap.


Compare and Swap (<mem LOC> <expected value>, <new value>)
{
if (<mem LOC> = = <expected value>)
{
<mem LOC> = <new value>;
return 0;
}
else
{
return 1;
}

SY
}
The enter_CS and leave_CS function to implement critical section are as following where x is a mem
location associated with CS initialized to 1.
Void enter_CS (X)
{
while (compare-and-swap (<x>,1,0));
}
Void leave_CS (x)
EA
{
<x> = 1;
}
Now, consider the following statements:
1. More than one process can enter CS at the same time.
E

2. The above solution to CS_problem is deadlock free.


Which of the above statements are correct?
(a) Both 1 and 2 (b) Only 1
AD

(c) Only 2 (d) None of these

26. (c)
Given function compare and swap is like test and set. Or, we can say that test and set is just a special
case of compare and swap, which maintain mutual exclusion and is deadlock free.
M

15 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.27 Consider the following proposed solution to dining Philosopher’s problem to avoid deadlock. Consider the
binary semaphore lock is initialized to 1.
Philosopher (int i)
{
while (1)
{
think ( );
wait (lock); ...(i)
wait (fork [i]);
wait (fork [(i +1)%5]);
signal (lock); ...(ii)
eat ( );

SY
wait (lock); ...(iii)
signal (fork [i]);
signal (fork (i +1)%5);
signal (lock); ...(iv)
}
Which of the following is correct?
EA
(a) Removing (i) and (ii) will not affect the code. The code will still work fine.
(b) Removing (iii) and (iv) will not affect the code. The code still work fine.
(c) Removing both (i), (ii), (iii) and (iv) will not affect the code. The code will still work fine.
(d) All (i), (ii), (iii) and (iv) are necessary. Removal of any of them will affect the code.

27. (b)
If, we remove the lock while acquiring the fork. It may lead to deadlock, if all process execute (i) statement
before any philosopher has execute (ii) statement.
E

Removal of (iii) and (iv) will not affect the code, since no conflict can occur doing the V operation on forks.

Q.28 The following program consist of 4 concurrent processes and 3 counting semaphores a, b and c
AD

Process 1 Process 2 Process 3 Process 4


wait (a) wait (c) wait (b) wait (a)
print “G” print “A” print “T” wait (b)
signal (b) signal (c) signal (a) print “E”
signal (b) signal (a)

What must be the initial values of the three semaphores, so that output ‘TGE’ is obtained?
(a) a = 1, b = 1, c = 0 (b) a = 0, b = 1, c = 1
M

(c) a = –1, b = 1, c = 1 (d) a = 0, b = 1, c = –1

28. (d)
The output is ‘TGE’. So, to print ‘T’, we must give a value of 1 to semaphore b and should block rest three
processes.
Now, process 3, after printing T, will give signal to semaphore a, which will wake up process 1 and will print
‘G’ and given signal to semaphore ‘b’ and ‘c’. On giving signal to semaphore ‘c’, process ‘2’ will get
awake. But ‘a’ should not be printed in the output hence ‘c’ should be given value ‘–1’.
Process 4 will also awake after process 3 on signal ‘a’, but it will again be blocked by wait (b).

16 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Numerical Data Type Questions : Q.29 to Q.33 carry 2 marks each

Q.29 Consider the following set of processes, with the arrival times and CPU burst times given in milliseconds
P. No. Burst time Arrival time
P1 35 0
P2 25 5
P3 10 20
P4 20 45
P5 15 65

The difference between the average turnaround time for these processes for FCFS and shortest remaining
time policy is _________.
[Note : When two processes have same burst time then the tie is removed by minimum arrival time.]

29. (8)

SY
P1 P2 P3 P4 P5
0 35 60 70 90 105

P1 P2 P3 P4 P5
Calculating TTAAT:
P1 : 35 – 0 = 35
P2 : 60 – 5 = 55
P3 : 70 – 20 = 50
P4 : 90 – 45 = 45
EA
P5 : 105 – 65 = 40
35 + 55 + 50 + 45 + 40
Avg TAT = = 45
5
SRT:
SRT
P1 P2 P2 P3 P1 P4 P5 P1
E

0 5 20 30 40 45 65 80 105

P2 P3 P4 P5 P1
AD

Calculating TTAAT:
P1 : 105 – 0 = 105
P2 : 30 – 5 = 25
P3 : 40 – 20 = 20
P4 : 65 – 45 = 20
P5 : 80 – 65 = 15
M

105 + 25 + 20 + 20 + 15
Avg TAT = = 37
5
Difference = 45 – 37 = 8

17 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.30 The wait and signal operation on a semaphore S is implemented as:


wait operation on S signal operation on S
wait(S1); wait(S1);
C -- ; C ++;
if(C < 0) if(C <= 0)
{ signal(S2);
signal(S1); else
wait(S2); signal(S1);
}
signal(S1);

Consider that the initial values of S1 = 1, S2 = 0 and C is set to the initial value of S i.e., 7. Then 5 wait
operations and 3 signal operations were completed on the semaphore S. The resulting value of S
is____________.

SY
30. (5)
Let’s first analyze the wait and signal code;
Wait code: Initially value of C is 7, S1 = 1, S2 = 0
wait (S1) → S1 = 0
C - -; → C = 6
If (value of C is less than 0, the thread is blocked by applying wait (S2).
EA
Hence, it can be seen that, it is the code for counting semaphore wait operation, implemented with the
help of binary semaphore.
Similarly, for signal code
S=7–5=2+3=5

Q.31 Consider four process all are arriving at time zero, with total execution time of 20, 10, 10 and 20 unit
respectively. Each process spends the first 20% of execution time doing CPU, the next 60% of doing I/O
computation and the last 20% of time doing CPU computation again. The operating system uses longest
E

time first scheduling algorithm and schedules a new process either when running process get blocked I/O
or when the running process finishes its CPU burst.
Assume that I/O operations can be overlapped as much as possible. The average TAT of the system
AD

given by ______ unit.


[Note: When same burst occurs for multiple process high priority given to lowest process id] (upto one
decimal place)

31. 24.5 (24.40 - 24.60)

Process Burst Time CPU I/O CPU CT TAT


M

P0 20 4 12 4 20 20
P1 10 2 6 2 26 26
P2 10 2 6 2 28 28
P3 20 4 12 4 24 24
Average TAT = 98/4 = 24.5

Gantt Chart

P0 P3 P3 P3 P3 P1 P1 P2 P2 P0 P0 P0 P0 P3 P1 P2

0 4 5 6 7 8 9 10 11 12 16 17 18 19 20 24 26 28
P0 P0 P0 P0 P0 P0 P0 P0 P2 P2 P3 P3
(I/O) (I/O) (I/O) (I/O) P3 P3 P3 P3 P3 P3 (I/O) (I/O)
(I/O) (I/O) P2 P1 (I/O) (I/O)
(I/O) (I/O)

18 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY


Delhi | Noida | Bhopal | Hyderabad | Jaipur | Indore
Lucknow | Pune | Bhubaneswar | Kolkata | Patna GTOCS17

Q.32 A system uses optimal policy for a page replacement. It has 4 page frames with no pages loaded to begin
with. Consider the following scenario
Case-1: System first accesses 200 distinct pages in sequential order and then access same 200 distinct
pages in same order.
Case-2: System first accesses 200 distinct pages in sequential order and then access same 200 distinct
page in reverse order.
The difference in the number of faults occurred in both case are _________.

32. (0)
Case-1: System accesses 200 distinct pages. So, all these 200 pages are the page fault, next these
pages are accessed again, at that time page number 1, 2, 3 and 200 are in the frame. Now, when 4 will be
accessed, it will be replaced by 1. Next when 5 will be accessed, it will also be replaced by 2 and so on

SY
till 199. So, total page faults = 200 + 196 = 396
Case-2: Again after the first access is over 197, 198, 199 and 200 are in the page frame. From 196 to 1 will
be fault. So, total page faults = 200 + 196 = 396
Difference = 396 – 396 = 0

Q.33 An operating system uses the Banker’s Algorithm for deadlock avoidance when managing the allocation
of three resources types X, Y and Z to five processes. Consider the following scenario

Process
EA
X
Allocated
Y Z X
Maximum
Y Z X
Available
Y Z
P0 0 1 0 7 5 3 3 3 2
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

Total possible safe sequences are _________.


E

33. (16)
Calculating the need matrix
AD

Need
Process
X Y Z
P0 7 4 3
P1 1 2 2
P2 6 0 0
P3 0 1 1
P4 4 3 1

Since, the available resources are 〈3, 3, 2〉.


M

Hence the request can only be satisfied for P1 or P3 at initial stage.


Considering P3 first,
Available after P3 → 〈3, 3, 2〉 – 〈0, 1, 1〉 = 〈3, 2, 1〉 + 〈2, 2, 2 〉 = 〈5, 4, 3〉
After P3 only, P1 or P4 can be executed.
Considering P1 first, rest all three processes can be scheduled in any way hence 6 possible ways.
After P3, consider P4, Next P1 can only be scheduled, then P0 and P2 can be scheduled in any way hence
2 possible ways.
Considering P1 now: Need after P1 → 〈3, 3, 2〉 – 〈1, 2, 2〉 = 〈2, 1, 0〉 + 〈3, 2, 2〉 = 〈5, 3, 2〉
Now, condition can be satisfied either for P3 or P4.
Considering P3 first, any possible combination on P0, P4 and P2 possible hence 6 sequence.
Considering P4 first, followed by P3, then any combination of P0 and P1 hence sequence.
Total = 16 sequences.

„„„„
19 • Operating System (Basic Level) www.madeeasy.in © Copyright : MADE EASY

You might also like