Os MCQ
Os MCQ
Os MCQ
if (fork() == 0)
{ a = a + 5; printf("%d,%dn", a, &a); }
else { a = a –5; printf("%d, %dn", a, &a); }
Let u, v be the values printed by the parent process, and x, y be the values printed by the child process.
Which one of the following is TRUE?
A) u = x + 10 and v = y
B) u = x + 10 and v = !y
C) u + 10= x and v = y
D) u + 10 = x and v = !y
Q2: Three concurrent processes X, Y, and Z execute three different code segments that access and
update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b
and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P
operation on semaphores c, d, and a before entering the respective code segments. After completing
the execution of its code segment, each process invokes the V operation (i.e., signal) on its three
semaphores. All semaphores are binary semaphores initialised to one. Which one of the following
represents a deadlock free order of invoking the P operations by the processes? \
A) -2
B) -1
C) 1
D) 2
Q4: A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i])
for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such
that X computes the array a and Y computes the array b. The processes employ two binary semaphores
R and S, both initialised to zero. The array a is shared by the two processes. The structures of the
processes are shown below.
Process X: Process Y:
private i; private i;
for (i=0; i < n; i++) { for (i=0; i < n; i++) {
a[i] = f(i); EntryY(R, S);
ExitX(R, S); b[i]=g(a[i]);
} }
Which one of the following represents the CORRECT implementations of ExitX and EntryY?
(A)
ExitX(R, S) {
P(R);
V(S);
}
EntryY (R, S) {
P(S);
V(R);
}
(B)
ExitX(R, S) {
V(R);
V(S);
}
EntryY(R, S) {
P(R);
P(S);
}
(C)
ExitX(R, S) {
P(S);
V(R);
}
EntryY(R, S) {
V(S);
P(R);
}
(D)
ExitX(R, S) {
V(R);
P(S);
}
EntryY(R, S) {
V(S);
P(R);
}
Q5: Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8
time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF)
scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest
process id. The average turn around time is:
A) 13 units
B)14units
C)15 units
D) 16 units
Q7: Consider the following table of arrival time and burst time for three processes P0, P1 and P2.
Process Arrival time Burst Time
P0 0 ms 9 ms
P1 1 ms 4 ms
P2 2 ms 9 ms
The pre-emptive shortest job first scheduling algorithm is used. Scheduling is carried out only at
arrival or completion of processes. What is the average waiting time for the three processes?
A) 5.0 ms
B) 4.33 ms
C) 6.33 ms
D) 7.33 ms
Q8: Consider a uniprocessor system executing three tasks T1, T2 and T3, each of which is composed
of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 3, 7 and 20
milliseconds, respectively. The priority of each task is the inverse of its period and the available tasks
are scheduled in order of priority, with the highest priority task scheduled first. Each instance of T1,
T2 and T3 requires an execution time of 1, 2 and 4 milliseconds, respectively. Given that all tasks
initially arrive at the beginning of the 1st milliseconds and task preemptions are allowed, the first
instance of T3 completes its execution at the end of ______________ milliseconds.
A) 5
B) 10
C) 12
D) 15
Q9: Consider the virtual page reference string 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 On a demand paged virtual
memory system running on a computer system that main memory size of 3 pages frames which are
initially empty. Let LRU, FIFO and OPTIMAL denote the number of page faults under the
corresponding page replacements policy. Then
Q10: 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
Q11: A paging scheme uses a Translation Look-aside Buffer (TLB). A TLB-access takes 10 ns and
a main memory access takes 50 ns. What is the effective access time(in ns) if the TLB hit ratio is 90%
and there is no page-fault?
A) 54
B) 60
C) 65
D) 75
Q12: If the page size in a 32-bit machine is 4K bytes then the size of page table is
A) 1 M bytes
B) 2 M bytes
C) 4 M bytes
D) 4 K bytes
Q13: Consider a 32-bit machine where four-level paging scheme is used. If the hit ratio to TLB is
98%, and it takes 20 nanosecond to search the TLB and 100 nanoseconds to access the main memory
what is effective memory access time in nanoseconds?
A) 126
B) 128
C) 122
D) 120
Q14: An operating system uses the Banker’s algorithm for deadlock avoidance when managing the
allocation of three resource types X, Y, and Z to three processes P0, P1, and P2. The table given
below presents the current system state. Here, the Allocation matrix shows the current number of
resources of each type allocated to each process and the Max matrix shows the maximum number of
resources of each type required by each process during its execution.
There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is
currently in a safe state. Consider the following independent requests for additional resources in the
current state:
REQ1: P0 requests 0 units of X,
0 units of Y and 2 units of Z
REQ2: P1 requests 2 units of X,
0 units of Y and 0 units of Z
Which one of the following is TRUE?
Q14: Suppose n processes, P1, …. Pn share m identical resource units, which can be reserved and
released one at a time. The maximum resource requirement of process Pi is Si, where Si > 0. Which
one of the following is a sufficient condition for ensuring that deadlock does not occur?
Q16: Consider the requests from processes in given order 300K, 25K, 125K and 50K. Let there be
two blocks of memory available of size 150K followed by a block size 350K.
Which of the following partition allocation schemes can satisfy above requests?
A) Best fit but not first fit.
B) First fit but not best fit.
C) Both First fit & Best fit.
D) neither first fit nor best fit.
Q18: Two processes, P1 and P2, need to access a critical section of code. Consider the following
synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which
are initialized to false. Which one of the following statements is TRUE about the above construct?
/* P1 */
while (true) {
wants1 = true;
while (wants2 == true);
/* Critical
Section */
wants1=false;
}
/* Remainder section */
/* P2 */
while (true) {
wants2 = true;
while (wants1==true);
/* Critical
Section */
wants2 = false;
}
/* Remainder section */
Q19: Consider the following statements about user level threads and kernel level threads. Which one
of the following statement is FALSE?
(A) Context switch time is longer for kernel level threads than for user level threads.
(B) User level threads do not need any hardware support.
(C) Related kernel level threads can be scheduled on different processors in a multi-processor system.
(D) Blocking one kernel level thread blocks all related threads.
21. Let m[0]…m[4] be mutexes (binary semaphores) and P[0] …. P[4] be processes.
Suppose each process P[i] executes the following:
wait (m[i]); wait(m[(i+1) mode 4]);
------
release (m[i]); release (m[(i+1)mod 4]);
This could cause
(a) Thrashing
(b) Deadlock
(c) Starvation, but not deadlock
(d) None of the above
Answer: (b)
22. Consider a virtual memory system with FIFO page replacement policy. For an arbitrary page access
pattern, increasing the number of page frames in main memory will (
a) Always decrease the number of page faults
b) Always increase the number of page faults
c) Some times increase the number of page faults
d) Never affect the number of page faults
Answer: (c)
23. Normally user programs are prevented from handling I/O directly by I/O instructions in them. For CPUs
having explicit I/O instructions, such I/O protection is ensured by having the I/O instructions privileged. In
a CPU with memory mapped I/O, there is no explicit I/O instruction. Which one of the following is true for a
CPU with memory mapped I/O?
(a) I/O protection is ensured by operating system routine(s)
(b) I/O protection is ensured by a hardware trap
(c) I/O protection is ensured during system configuration
(d) I/O protection is not possible
Answer (a)
24. Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time
units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling
algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. The
average turn around time is:
(A) 13 units
(B) 14 units
(C) 15 units
(D) 16 units
Answer (A)
26. Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units,
respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing
computation, and the last 10% of time doing I/O again. The operating system uses a shortest remaining
compute time first scheduling algorithm and schedules a new process either when the running process
gets blocked on I/O or when the running process finishes its compute burst. Assume that all I/O
operations can be overlapped as much as possible. For what percentage of time does the CPU remain
idle?
(A) 0%
(B) 10.6%
(C) 30.0%
(D) 89.4%
Answer (B)
27. Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2
and 6, respectively. How many context switches are needed if the operating system implements a shortest
remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.
(A) 1
(B) 2
(C) 3
(D) 4
Answer (B)
28. A computer system supports 32-bit virtual addresses as well as 32-bit physical addresses. Since the
virtual address space is of the same size as the physical address space, the operating system designers
decide to get rid of the virtual memory entirely. Which one of the following is true?
(A) Efficient implementation of multi-user support is no longer possible
(B) The processor cache organization can be made more efficient now
(C) Hardware support for memory management is no longer needed
(D) CPU scheduling can be made more efficient now
Answer (C)
29. A single processor system has three resource types X, Y and Z, which are shared by three processes.
There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes
the number of units of each resource type allocated to each process, and the column request denotes the
number of units of each resource type requested by a process in order to complete execution. Which of
these processes will finish LAST?
alloc request
X Y Z X Y Z
P0 1 2 1 1 0 3
P1 2 0 1 0 1 2
P2 2 2 1 1 2 0
(A) P0
(B) P1
(C) P2
(D) None of the above, since the system is in a deadlock
Answer (C)
30. Two processes, P1 and P2, need to access a critical section of code. Consider the following
synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which
are initialized to false. Which one of the following statements is TRUE about the above construct?
/* P1 */
while (true) {
wants1 = true;
while (wants2 == true);
/* Critical
Section */
wants1=false;
}
/* Remainder section */
/* P2 */
while (true) {
wants2 = true;
while (wants1==true);
/* Critical
Section */
wants2 = false;
}
/* Remainder section */
(A) It does not ensure mutual exclusion.
(B) It does not ensure bounded waiting.
(C) It requires that processes enter the critical section in strict alternation.
(D) It does not prevent deadlocks, but ensures mutual exclusion.
Answer (D)
31. An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm.
Consider the arrival times and execution times for the following processes:
Process Execution time Arrival time
P1 20 0
P2 25 15
P3 10 30
P4 15 45
What is the total waiting time for process P2?
(A) 5
(B) 15
(C) 40
(D) 55
Answer (B)
Answer (B)
33. In the following process state transition diagram for a uniprocessor system, assume that there are
always some processes in the ready state: Now consider the following statements:
I. If a process makes a transition D, it would result in another process making transition A immediately.
II. A process P2 in blocked state can make transition E while another process P1 is in running state.
III. The OS uses preemptive scheduling.
IV. The OS uses non-preemptive scheduling.
Which of the above statements are TRUE?
(A) I and II
(B) I and III
(C) II and III
(D) II and IV
Answer (C)
34. The enter_CS() and leave_CS() functions to implement critical section of a process are realized using
test-and-set instruction as follows:
void enter_CS(X)
{
while test-and-set(X) ;
}
void leave_CS(X)
{
X = 0;
}
In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider
the following statements:
I. The above solution to CS problem is deadlock-free
II. The solution is starvation free.
III. The processes enter CS in FIFO order.
IV More than one process can enter CS at the same time.
Which of the above statements is TRUE?
(A) I only
(B) I and II
(C) II and III
(D) IV only
Answer (A)
36. 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
Answer (B)
Answer: (c)
Answer (C)
41.Which of the following need not necessarily be saved on a context switch between processes?
a)General purpose registers
b)Translation look aside buffer
c)Program counter
d)All of the above
42. Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S)
increments S. During an execution, 20 P(S) operations and 12 V(S) operations are issued in some
order. The largest initial value of S for which at least one P(S) operation will remain blocked is
________.
a) 7
b) 8
c) 9
d) 10
44. An operating system implements a policy that requires a process to release all resources before
making a request for another resource. Select the TRUE statement from the following:
a) Both starvation and deadlock can occur
b) Starvation can occur but deadlock cannot occur
c) Starvation cannot occur but deadlock can occur
d) Neither starvation nor deadlock can occur
45. Which of the following actions is/are typically not performed by the operating system when
switching context from process A to process B?
a) Saving current register values and restoring saved register values for process B.
b) Changing address translation tables.
c) Swapping out the memory image of process A to the disk.
d) Invalidating the translation look-aside buffer.
50. Which of the following process scheduling algorithm may lead to starvation
a) FIFO
b) Round Robin
c) Shortest Job Next
d) None of the above
52. Consider a set of n tasks with known runtimes r1, r2, .... rn to be run on a uniprocessor machine.
Which of the following processor scheduling algorithms will result in the maximum throughput?
a) Round-Robin
b) Shortest-Job-First
c) Highest-Response-Ratio-Next
d)First-Come-First-Served
53. A system contains three programs and each requires three tape units for its operation. The
minimum number of tape units which the system must have such that deadlocks never arise is
_________.
a) 6
b)7
c )8
d)9
54. A system has 6 identical resources and N processes competing for them. Each process can
request atmost 2 resources. Which one of the following values of N could lead to a deadlock?
a)1
b)2
c)3
d)4
55. The maximum number of processes that can be in Ready state for a computer system with n
CPUs is
a) n
b) n2
c) 2n
d) Independent of n
56. Which of the following is not an optimization criterion in the design of a CPU scheduling
algorithm?
a) Minimum CPU utilization
b) Maximum throughput
c) Minimum turnaround time
d)Minimum waiting time
57 Which of the following is major part of time taken when accessing data on the disk?
a)Settle time
b)Rotational latency
c)Seek time
d) Waiting time
60. Which of the following devices should get higher priority in assigning interrupts?
a)Hard disk
b)Printer
c)Keyboard
d)Floppy disk
61. Which module gives control of the CPU to the process selected by the short - term schedular ?
a)Dispatcher
b)Interrupt
c)Schedular
d)Threading
62 A state is safe, if :
a) the system does not crash due to deadlock occurrence
b) the system can allocate resources to each process in some order and still avoid a deadlock
c) the state keeps the system protected and safe
d) all of the mentioned
66 Response time is :
a) the total time taken from the submission time till the completion time
b) the total time taken from the submission time till the first response is produced
c) the total time taken from submission time till the response is output
d) none of the mentioned
69. Which process can be affected by other processes executing in the system?
a) cooperating process
b) child process
c) parent process
d) init process
70. If a process is executing in its critical section, then no other processes can be executing in their
critical section. This condition is called
a) mutual exclusion
b) critical exclusion
c) synchronous exclusion
d) asynchronous exclusion
78. Every address generated by the CPU is divided into two parts :
a) frame bit & page number
b) page number & page offset
c) page offset & frame bit
d) frame offset & page offset
80. Which algorithm chooses the page that has not been used for the longest period of time
whenever the page required to be replaced?
a) first in first out algorithm
b) additional reference bit algorithm
c) least recently used algorithm
d) counting based page replacement algorithm
Answer: A
82. The total time to prepare a disk drive mechanism for a block of data to be read from it is
(A) seek time
(B) Latency
(C) latency plus seek time
(D) transmission time
Answer: C
83. Access to moving head disks requires three periods of delay before information is brought into
memory. The response that correctly lists the three time delays for the physical access of data in the
order of the relative speed from the slowest to the fastest is
(A) latency time, cache overhead time, seek time
(B) transmission time, latency time, seek time
(C) seek time, latency time, transmission time
(D) cache overhead time, latency time, seek time
Answer: C
84. Thrashing
(A) the high paging activity
(B) is spending more time in paging than
executing
(C) both A and B
(D) none of the above
Answer: C
85. Stub
(A) is included in the image for each library routine reference
(B) is small piece of code that indicates how to locate the appropriate memory resident library
routine
(C) how to load the library if the routine is not already present
(D) all of the above
Answer: D
86. Match the following in RAID scheme : A- Parallel access array, B-Independent access array, 1-
All member disks participate in the execution of every I/O request. 2- Each member disk
participates separately in the execution of every I/O request. 3- Here spindles of the individual
drives are synchronized so that each disk head is in the same position on each disk at any given
time.
(A) A–1,3 and B–2
(B) A–1, and B–2,3
(C) A–2 and B–1,3
(D) A–1,2 and B–3
Answer: A
87. Consider six memory partitions of sizes 200 KB, 400 KB, 600 KB, 500 KB, 300 KB and 250 KB, where KB
refers to kilobyte. These partitions need to be allotted to four processes of sizes 357 KB, 210KB, 468 KB and
491 KB in that order. If the best fit algorithm is used, which partitions are NOT allotted to any process?
88. The maximum number of processes that can be in Ready state for a computer system with n CPUs is
A:n
B : n^2
C : 2^n
D : Independent of n
Two processes X and Y need to access a critical section. Consider the following
synchronization construct used by both the processes.
Here, var P and var Q are shared variables and both are initialized to false. Which one of
the following statements is true?
A : The proposed solution prevents deadlock but fails to guarantee mutual exclusion
B : The proposed solution guarantees mutual exclusion but fails to prevent deadlock
C : The proposed solution guarantees mutual exclusion and prevents deadlock
D : The proposed solution fails to prevent deadlock and fails to guarantee mutual exclusion
90. For the processes listed in the following table, which of the following scheduling
schemes will the lowest average turnaround time?
Process Arrival Time Processing time
A 0 3
B 1 6
C 4 4
D 6 2
92. Let the time taken to switch between user and kernel modes of execution be t1
while the time taken to switch between two processes be t2. Which of the following
is TRUE?
A : t1 > t2
B : t1 = t2
C : t1 < t2
D : Nothing can be said about the relation between t1 and t2
A:3
B:4
C:7
D:8
97. Consider a system with 4 types of resources R1 (3 units), R2 (2 units), R3 (3 units), R4 (2 units). A non-
preemptive resource allocation policy is used. At any given instance, a request is not entertained if it cannot
be completely satisfied. Three processes P1, P2, P3 request the sources as follows if executed independently.
Process P1:
t=0: requests 2 units of R2
t=1: requests 1 unit of R3
t=3: requests 2 units of R1
t=5: releases 1 unit of R2 and 1 unit of R1.
t=7: releases 1 unit of R3
t=8: requests 2 units of R4
t=10: Finishes
Process P2:
t=0: requests 2 units of R3
t=2: requests 1 unit of R4
t=4: requests 1 unit of R1
t=6: releases 1 unit of R3
t=8: Finishes
Process P3:
t=0: requests 1 unit of R4
t=2: requests 2 units of R1
t=5: releases 2 units of R1
t=7: requests 1 unit of R2
t=8: requests 1 unit of R3
t=9: Finishes
Which one of the following statements is TRUE if all three processes run concurrently starting at time t=0?
A : All processes will finish without any deadlock
B : Only P1 and P2 will be in deadlock.
C : Only P1 and P3 will be in a deadlock.
D : All three processes will be in deadlock
98. Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed,
as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.
Method Used by P1
while (S1 == S2) ;
Critical Section
S1 = S2;
Method Used by P2
while (S1 != S2) ;
Critical Section
S2 = not (S1);
Which one of the following statements describes the properties achieved?
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are
initialized as S0=1, S1=0, S2=0. How many times will process P0 print ‘0’?
A : At least twice
B : Exactly twice
C : Exactly thrice
D : Exactly once
100. A system has n resources R0,...,Rn-1,and k processes P0,....Pk-1.The implementation of the resource
request logic of each process Pi is as follows:
if (i % 2 == 0) {
if (i < n) request Ri if (i+2 < n) request Ri+2
}
else {
if (i < n) request Rn-i
if (i+2 < n) request Rn-i-2
}
In which one of the following situations is a deadlock possible?
A : n=40, k=26
B : n=21, k=12
C : n=20, k=10
D : n=41, k=19