Operating Systems Test - 2 - PDF Flipbook

Operating Systems Test - 2

431 Views
77 Downloads
PDF 4,995,278 Bytes

Download as PDF

REPORT DMCA


GATE
CSE

Operating
systems

Test-02Solutions


OPERATING SYSTEMS
1. The term 'aging' refers to

a) Booting up the priority of the process in multi-level of queue
without feedback.

b) gradually increasing the priority of jobs that wait in the
system for a long time to remedy infinite blocking

c) keeping track of the following a page has been in memory for
the purpose of LRU replacement

d) Letting job reside in memory for a certain amount of time so
that the number of pages required can be estimated
accurately.

Answer: (b)
Solution:
Priority scheduling algorithm suffers from the problem of
starvation. There might be the case that some low priority
process does not get CPU, because of high priority processes. A
solution to this problem is aging. Aging refers to gradually
increasing the priority of jobs that wait in the system for a long
time to remedy infinite blocking.
2. Consider this C code to swap two integers and these five
statements: the code

Void swap (int *px, int *py)
{
*px=*px-*py;
*py= *px + *py;

1


*px =*py- *px;
}
a) S1: will generate a compilation error
b) S2: may generate a segmentation fault at runtime depending
on the arguments passed
c) S3: correctly implements the swap procedure for all input
pointers referring to integers stored in memory locations
accessible to the process
d) S4: implements the swap procedure correctly for some but
not all valid input pointers
e) S5: may add or subtract integers and pointers.
a) S1
b) S5 and S3
c) S2 and S4
d) S2 and S5
Answer: (b)
Solution:
S2: On execution the code will generate a runtime error on line
L1
S3: On execution the code will generate a runtime error on line
L2
3. A page fault
a) Occurs when a program accesses an available page on
memory
b) is an error in a specific page

2


c) is a reference to a page belonging to another program
d) occurs when a program accesses a page not currently in

memory
Answer: (d)
Solution:
Page fault occur when OS refer some page in memory but it is
not present. So a trap is generated and page is brought into main
memory from hard disk.
4. The process of assigning load addresses to the various parts of
the program and adjusting them code and data in the program to
reflect the assigned addresses is called
a) Assembly
b) Parsing
c) Relocation
d) Symbol resolution
Answer: (c)
Solution:
This is done during loading & execution of the program.
5. Dirty bit for a page in a page table
a) helps avoid unnecessary writes on a paging device
b) helps maintain LRU information
c) allows only read on a page
d) none of these
Answer: (a)

3


6. Consider a system with byte-addressable memory, 32-bit logical

addresses, 4 kilobyte page size and page table entries of 4 bytes

each. The size of the page table in the system in megabytes is

_____.

Answer: 4

Solution:

Number of entities in page table = 232 = 232 = 220
4 212

Page table entries = 4 bytes

Size of the page table = 220 × 4B = 4MB

7. A CPU generally handles an interrupt by executing an interrupt

service routine

a) as soon as an interrupt is raised

b) by checking the interrupt register at the end of fetch cycle

c) by checking the interrupt register after finishing the executing

the current instruction

d) by checking the interrupt register at fixed time intervals

Answer: (c)

Solution:

After finishing the execution of each instruction the CPU reads

the interrupt pins to recognize the interrupts.

8. Equivalence partitioning is a testing method that divides the

input domain of a program into classes of data from which test

cases can be derived.

a) White box

b) Black box

4


c) Regression
d) Smoke
Answer: (b)
Solution:
The tendency is to related equivalence partitioning to so call
black box testing which is strictly checking a software
component as its interface, without consideration of internal
structure of the software.
9. Which of the deadlock?
a) Time out
b) Time in
c) Both (a)and (b)
d) None of these
Answer: (a)
Solution:
Covariance is a measure of how much two random variables
changes to gather
So when pixel of an image suffered then covariance is changed
10. Faster access to non-local variables is achieved using an array
of pointers to activation records called a
a) stack
b) heap
c) display
d) activation tree
Answer: (c)

5


Solution:

Using display (or multi-level access link) we can access non-

local variables.

11. In an enhancement of a CPU design, the speed of a floating-

point unit has been increased by 20% and the speed of a fixed-

point unit has been increased by10%. What is the overall speed

achieved if the ratio of the number of floating point operation to

the number fixed point operations is 2:3 and the floating-point

operation used to take twice in the time taken by the fixed-point

operation in original design?

a) 1.162

b) 1.155

c) 1.185

d) 1.285

Answer: (b)

Solution:

Speedup = Original time taken
New time tken

Let x be time for a fixed point operation original time taken =

(3 +2×2 ) = 7
5 5

New time taken = �13. 1 �+�14. 2 �
5

= 8
1.32×5

Hence, speedup = 7×1.32 =1.155
8

6


12. Design phase will usually be
a) top-down
b) bottom-up
c) random
d) center fringing
Answer: (a)
Solution:
Design phone usually has a top down design approach. Top
down design is used to solve the complex problems it breaks the
problem into parts which helps us to clarify what needs to be
done. Break the problem into pars allows more than one person
to work on the situation. Parts of the solution may be turn out to
be reusable.

13. A processor needs software interrupt to
a) Test the interrupt system of the processor
b) Implement co-routines
c) Obtain system services which need execution of privileged
instructions
d) Return from subroutine
Answer: (c)
Solution:
Interrupt is used to shift from Non-privileged to privileged mode
where OS services runs.

7


14. Where does a computer and compare data?
a) Hard disk
b) Floppy disk
c) CPU chip
d) Memory chip
Answer: (c)
Solution:
A central processing unit (CPU) is the electronic circuity with in
a computer that carries out the instructions of computer program
by performing the basic Arithmetic, logical, control and input
output (I/O) operations specified by the instructions.

15. Match the following:
List-I (Process state transition)
A. Ready —* Running
B. Blocked Ready
C. Runnings ---> Blocked
D. Runnings Ready
List-II (Reason for transition)
1. Request made by the process is satisfied or an event for
which it was waiting occurs.
2. Process wishes to wait for some action by another process.
3. The process is dispatched.
4. The process is preempted

8


Code:
ABCD

a) 3 1 2 4
b) 4 1 3 2
c) 4 3 1 2
d) 3 3 2 1
Answer: (a)
Solution:
The state diagram for a process captures its life cycles. The
states represent the execution status of the process; the
transactions represent changes of execution states.

16. A CPU has two modes privileged and non-privileged. In order
to change the mode form privileged to non-privileged.
a) A hardware interrupt is needed
b) A software interrupt is needed
c) A privileged instruction (which does not generate an
interrupt) is needed
d) A non-privileged instruction (which does not generate an
interrupt) is needed.
Answer: (c)
Solution:
Non Interrupt is NOT needed as; we are already in Kernel mode.

9


17. The number of disk pages access in btree search, where his
height, n is the number of keys, and t is the minimum degree, is:
a) (logn h *t)
b) (logt n*h)
c) (logh n)
d) (logt n)
Answer: (d)
Solution:
As in the tree-search precedence for binary search trees, the
nodes encountered during the recursion from a path downward
from the root of the tree. The number of disk pages accessed by
B-tree search is therefore (h) = (logt (n))t, where h is the
height of the B-tree and n is the number of nodes and t is the
order of B-tree

18. Consider the fractional knapsack instance
n = 4, (P1, P2, P3, P4) = (10, 10, 12, 18),
(W1, W2, W3, W4) = (2, 4, 6, 9) and M = 15.
The maximum profit is given by (Assume p and w denotes
profit and weight of objects respectively)
a) 40
b) 38
c) 32
d) 30
Answer: (b)

10


Solution:

P1 P1 P1 P1

Profit(p) 10 10 12 18

Weight (w) 2 4 6 9

pilwi 5 2.5 2 2

Given, m =15

Therefore, when we include P1, P2, and P4 weight (2 + 4 + 9

=15) and

Maximum profit =10 +10 + 18 = 38

19. A system contains 10 units of resource of same type. The

resource requirement and current allocation of these resources

for three processes P, O and P are as follows:

PQR

Maximum requirement 8 7 5

Current allocation 41 5

Consider the following resource request:

(i) P makes a request for 2 resource units.

(ii) Q makes request for 2 resources units.

(iii) B makes a request of 2 resource units.

For a safe state, which of the following options must be

satisfied?

a) Only request (i)

b) Only request (ii)

c) Only request (iii)

d) Request (i) and (iv)

11


Answer: (c)

Solution:

Gantt chart is

BEACDEACEAEAEAA

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Therefore,

average TAT = 15+1+8+5+13 = 42 = 8.4 millisecond
5 5

20. Superficially the term "object-oriented", means that, we

organize software as a

a) collection of continuous objects that incorporates both data

structure and behavior

b) Collection of discrete objects that incorporates both discrete

structure and behavior.

c) Collection of discrete objects that incorporates both data

structure and behavior.

d) Collection of objects that incorporates both discrete data

structure and behavior.

Answer: (c)

Solution:

Superficially the term object-oriented (oo) means the that we

organize software as a collection of discrete objects that

incorporate both data structure and behavior

There is some dispute about exactly what characteristics are

required by an object oriented approach, but they generally

12


include four aspects: Identify classification, inheritance and
polymorphism.
21. Software Engineering is a discipline that nitrates for the
development of computer software.
a) Process
b) Methods
c) Tools
d) All of these
Answer: (d)
Solution:
Software engineering is a field of engineering, for designing and
writing programs for computers or other electronic devices.
A software engineer, or programmer, writes software (or
changes existing software) and compiles software using
methods that make it better quality.
22. The mean-end analysis process centers around the detection of
differences between the current state and goal state. Once such a
difference is isolated, an operator that can reduce the difference
must be found. But perhaps that operator cannot be applied to
the current state. So, a sub-problem of getting to a state in which
it can be applied is set up. The kind of backward chaining in
which operators are selected and then sub goals are set up to
establish the precondition of operators is called
a) backward planning
b) goal stack planning

13


c) operator sub galling
d) operator overloading
Answer: (c)
Solution:
The means –ends analysis process centers around the detection
of differences between current state and the goal state. One such
a difference is isolated, an operator that can be reduced the
difference must be found. But perhaps that operator cannot be
applied to the current state. So, we set up a sub problem of
getting to a state in which it can be applied
The kind of backward chaining in which operations are selected
and sub goals are setup to establish the preconditions of the
operator is called operator sub goaling
Operator sub goaling is computer problem solving method in
which the inability of the computer to take the desired next
step at any point in the problem solving process leads to a sub
goal of making that step feasible.
23. A UNIX file system has 1 KB block size and 4-byte disk
addresses. What is the maximum file size if the node contains
ten direct block entrees, one single indirect block entry, one
double indirect block entry and one triple indirect block entry?
a) 30 GB
b) 64 GB
c) 16 GB
d) 1GB

14


Answer: (c)

Solution:
Maximum file size = �DirecDt ibslkocbkloacdkdsriezses size�3× Disk block size

= �14 �3×1 K Bytes
= (28)3 × 1k Bytes

= 224 × 210 bytes

=16 × 230 bytes =16G bytes

24. On which of the following contents of Y and x does the

program fail?

a) Y is[1 2 3 4 5 6 7 8 9 10] and x < 10

b) Y is [1 3 5 7 9 11 17 19] and x < 1

c) Y is[2 4 6 8 10 16 14 16 18 20]

d) Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even

Answer: (c)

Solution:

When Y is [2 2 2 2 2 2 2 2 2 2] and x > 2, given binary search

can't search and the program fails.

25. Consider a hash table of size m = 10000 and the hash function

h(k) = [m (KA mod 1)] for. A = �√5−1� location to the key k =
2

123456 is

a) 46

b) 47

c) 41

d) 43

15


Answer: (c)
Solution:
Given a hash table with 10,000 slots, i.e.,
m = 10000, then the hash function.
h(k) = ⌊m(kA mod1)⌋
will map the key 12456 to slot 41. Since,
= ⌊10000 (76300.0041151 … mod1)⌋
= ⌊10000 (0.0041151)⌋ = ⌊41.151⌋ = 41
26. What is printed by the following C program?

int f(int x, int*py, int **ppz)
{
int y, z;
**py +=2; y=*py;
X +=3;
return x+ y+ z;
}
Void main()
{
Int c, *b, **a;
c = 4; b = &c; a = &b;
Printf(“%d”, f(c,b,a));

}
a) 18
b) 19
c) 21

16


d) 22
Answer: (b)
Solution:

F(c, b, a)


Int f(int x, int*py, int**ppz)


(4,100,200)
Return x+y+z
∴ x + y + z = 7 + 7 + 5 = 19
Consider the following C program that attempts to locate an
element x in an array Y[ ] using binary search. The program is
erroneous.
f(int Y[10], int x)
{
int i, j, k;
i=0; j=9;
Do
{
k= (i+j)/2;

17


if(Y[k]

Data Loading...