Operating System-Question Bank
Operating System-Question Bank
Operating System
3. The shell is
a) a hardware component b) a command interpreter
c) a part of compiler d) a tool in CPU Scheduling
3. Mention one essential characteristic each of time sharing system, batch processing system and
distributed system, real time system, network system.
5. What is bootstrapping?
6. What are the differences between a trap and an interrupt? What is the use of each function?
7. What is the purpose of the command interpreter? Why is it usually separate from the kernel?
3. Under what conditions the following state transition occurs with respect to a process?
i) Run to Ready, ii) Blocked (or wait) to Ready
4. What is context switching? Why is context switching considered to be time consuming?
6. With the help of state transition diagram, explain various states of a process.
Threads
1. Thread is referred to as
a) lightweight process b) process
c) program d) set of processes.
2. What are the relative advantages and disadvantages of user level thread and kernel level
thread?
4. What resources are used when a thread is created? How they differ when a process is created?
Process Scheduling
1. The technique of gradually increasing the priority of a process that wait in a system for a long
time is known as
a) blocking b) ageing
c) starvation d) convoy effect.
4. The average wait time for five processes P1-P5 with burst of 5, 19,2,16 and 7 milliseconds
respectively, using SJF is:
a) 5 milliseconds b) 10.6 milliseconds
c) 28.25 milliseconds d) 9.8 milliseconds
e) None of the above
5. Suppose that the operating system is running a non-preemptive scheduler and that process p is
currently running. A context switch can occur:
a) When p terminates or block b) When another process unblocks
c) When another process enters d) When the time quantum is exhausted
e) When the priority of some other process exceeds the priority of p.
9. Consider a set of n tasks with known runtimes r1, r2, … rn to be run on a uni-processor
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
10. 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
11. Assume that the following jobs are to be executed on a single processor system
-----------------------
Job-Id CPU-BurstTime
-----------------------
p 4
q 1
r 8
s 1
t 2
-----------------------
The jobs are assumed to have arrived at time 0 and in the order p, q, r, s, t. Calculate the
departure time (completion time) for job p if scheduling is round robin with time slice 1.
(a) 4 (b) 10 (c) 11 (d) 12
12. The sequence …………… is an optimal non-preemptive scheduling sequence for the
following jobs which leaves the CPU idle for ………………… unit(s) of time.
----------------------------
Job Arrival_Time Burst_Time
----------------------------
1 0.0 9
2 0.6 5
3 1.0 1
----------------------------
(a) {3,2,1),1 (b) (2,1,3},0
(c) {3,2,1),0 (d) {1,2,3},5
13. A uni-processor computer system only has two processes, both of which alternate 10 ms
CPU bursts with 90 ms I/O bursts. Both the processes were created at nearly the same time. The
I/O of both processes can proceed in parallel. Which of the following scheduling strategies will
result in the least CPU utilization (over a long period of time) for this system?
(a) First come first served scheduling
(b) Shortest remaining time first scheduling
(c) Static priority scheduling with different priorities for the two processes
(d) Round robin scheduling with a time quantum of 5 ms
14. Consider the following set of processes, with the arrival times and the CPU burst times given
in milliseconds.
-------------------------------------
Process Arrival-Time Burst-Time
-------------------------------------
P1 0 5
P2 1 3
P3 2 3
P4 4 1
-------------------------------------
What is the average turnaround time for these processes with the preemptive shortest remaining
processing time first (SROT) algorithm?
(a) 5.50 (b) 5.75 (c) 6.00 (d) 6.25
15. 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 turnaround time is:
(a) 13 units (b) 14 units (c) 15 units (d) 16 units
16. 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%
18. Consider the following set of processes with corresponding arrival times and burst times:
Process Arrival Time (units) CPU Burst Time (Units)
P1 0 6
P2 3 10
P3 5 8
P4 7 5
P5 10 6
Draw the Gantt chart considering Round Robin scheduling policy with time quantum = 4 units.
Calculate individual turnaround time and average waiting time.
19. What is priority scheduling? Can SJF scheduling be considered as priority scheduling?
Justify.
20. Consider the following set of processes, with the length of the CPU-burst time given in
millisecond:
Process Burst Time Arrival Time Priority
P1 10 0 3
P2 1 1 1
P3 2 2 3
P4 1 2 4
P5 5 3 2
i) Draw 2 Gantt charts Illustrate the execution of these processes a non-pre-emptive priority (a
smaller priority number implies a higher priority) and a RR (quantum = 1) scheduling.
ii) What is turnaround time of each process for each of the scheduling algorithms? Also find the
average turnaround time of the system?
iii) What are the average waiting time for 2 algorithms?
25. Consider the following set of process. CPU burst times of them are given in milliseconds.
Process CPU Burst Time (Units)
P1 15
P2 5
P3 7
P4 10
Draw the Gantt chart considering Round Robin scheduling policy with time quantum = 4 units.
Calculate average turnaround time and average waiting time.
26. Write short notes on Shortest Remaining Time First CPU Scheduling.
27. Given n processes to be scheduled on one processor; how many possible different schedulers
are there? Give a formula of n.
30. For the process listed in the table, draw a chart illustrating their execution using FCFS, SJF,
SRTF(SRJF), Round Robin (quantum =2) and calculate average turn-around time and average
waiting time.
Process Arrival Time Processing Time
A 0 8
B 1 4
C 2 9
D 3 5
Process Synchronization
1. A critical section is a program segment
a) Which avoids deadlock
b) Which should run in a certain specified amount of time
c) Which shared resources that are accessed
d) Which must be enclosed by a pair of semaphores operation, p and v.
2. A situation where several processes access and manipulate the same data concurrently and the
outcome of the execution depends on the particular order in which access takes place is called:
a) data consistency b) race condition
c) aging d) starvation
3. The segment of code in which the process may change common variables, update tables, write
into files in known as:
a) Program b) Critical section
c) Non-critical section d) Synchronization
4. The default remedy of starvation is
a) Ageing b) critical section
c) Mutual exclusion d) all of these
5. Part of the program where the shared memory accessed and which should be executed
indivisibly
a) Semaphores b) directory
c) Critical section d) mutual exclusion
8. 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 Method Used by P2
while (S1 == S2) ; while (S1 != S2) ;
Critica1 Section Critica1 Section
S1 = S2; S2 = not (S1);
9. A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4V (signal)
operations were completed on this semaphore. The resulting value of the semaphore is
(a) 0 (b) 8 (c) 10 (d) 12
10. 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
11. 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
12. The following program consists of 3 concurrent processes and 3 binary semaphores. The
semaphores are initialized as S0=1, S1=0, S2=0.
Process P0 Process P1 Process P2
while (true) { wait (S1); wait (S2);
wait (S0); Release (S0); release (S0);
print (0);
release (S1);
release (S2);
}
14. Two processes, P1 and P2, need to access a critical section of code. Consider the following
synchronization construct used by the processes:
/* P1 */ /* P2 */
while (true) { while (true) {
wants1 = true; wants2 = true;
while (wants2 == true); while (wants1==true);
/* Critical /* Critical
Section */ Section */
wants1=false; wants2 = false;
} }
/* Remainder section */ /* Remainder section */
Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the
following statements is TRUE about the above construct?
(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.
15. The atomic fetch-and-set x, y instruction unconditionally sets the memory location x to 1 and
fetches the old value of x in y without allowing any intervening access to the memory location x.
consider the following implementation of P and V functions on a binary semaphore .
void P (binary_semaphore *s) {
unsigned y;
unsigned *x = &(s->value);
do {
fetch-and-set x, y;
} while (y);
}
void V (binary_semaphore *s) {
S->value = 0;
}
Which one of the following is true?
(a) The implementation may not work if context switching is disabled in P.
(b) Instead of using fetch-and-set, a pair of normal load/store can be used
(c) The implementation of V is wrong
(d) The code does not implement a binary semaphore
16. Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each
process in the set arrives at the barrier and waits for all others to arrive and then all processes
leave the barrier. Let the number of processes in the set be three and S be a binary semaphore
with the usual P and V functions. Consider the following C implementation of a barrier with line
numbers shown on left.
The variables process_arrived and process_left are shared among all processes and are initialized
to zero. In a concurrent program all the three processes call the barrier function when they need
to synchronize globally.
The above implementation of barrier is incorrect. Which one of the following is true?
(a) The barrier implementation is wrong due to the use of binary semaphore S
(b) The barrier implementation may lead to a deadlock if two barrier in invocations are used in
immediate succession.
(c) Lines 6 to 10 need not be inside a critical section
(d) The barrier implementation is correct if there are only two processes instead of three. Ans:
option (b)
17. What are the operations on a semaphore? What are the problems with these operations if these
follow the classical definition? What is the possible remedy to the above problem?
20. What is semaphore? What are the different types of semaphore? How is it used to overcome
critical section problem?
21. Define critical section and identify the requirements to be satisfied to solve the critical
section problem.
22. What is the Dining philosopher problem? Device an algorithm to solve the problem using
semaphore.
23. How mutual exclusion, hold & wait and circular wait are different from each other? Explain
with an example.
24. How does the monitor give the solution for synchronization problem?
25. Explain whether any integer variable with the similar operation can act as semaphore or not.
26. What are the problems of busy wait implementation of semaphore? Explain how it is solved.
27. State producer-consumer problem. Give a solution to the producer-consumer problem using
semaphore. Justify your solution guarantees Mutual Exclusion.
Deadlock
1. Computer system has 6 tape drives, with n processes competing for them. Each process may
need 2 tape drives. The maximum value of n for which the system is guaranteed to be deadlock
free is
a) 6 b) 5
c) 4 d) 3.
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?
(A) Only REQ1 can be permitted.
(B) Only REQ2 can be permitted.
(C) Both REQ1 and REQ2 can be permitted.
(D) Neither REQ1 nor REQ2 can be permitted
5.A system shares 9 tape drives. The current allocation and maximum requirment of tape drives
for three processes are shown below:
Process Current Allocation Maximum Requirment
P1 3 7
P2 1 6
P3 3 5
Which of the following best describes current state of the system?
(A) Safe, Deadlocked (B) Safe, Not Deadlocked
(C) Not Safe, Deadlocked (D) Not safe, Not Deadlocked
6.A system has 6 identical resources and N processes competing for them. Each process can
request at most 2 resources. Which one of the following values of N could lead to a deadlock?
(A) 1 (B) 2
(C) 3 (D) 4
7.Consider the following policies for preventing deadlock in a system with mutually exclusive
resources.
I. Processes should acquire all their resources at the beginning of execution. If any resource is
not available, all resources acquired so far are released.
II. The resources are numbered uniquely, and processes are allowed to request for resources only
in increasing resource numbers
III. The resources are numbered uniquely, and processes are allowed to request for resources
only in decreasing resource numbers
IV. The resources are numbered uniquely. A process is allowed to request only for a resource
with resource number larger than its currently held resources
Which of the above policies can be used for preventing deadlock?
(A) Any one of I and III but not II or IV
(B) Any one of I, III, and IV but not II
(C) Any one of II, and III but not I or IV
(D) Any one of I, II, III, and IV
8.A system has n resources R0…Rn-1, and k processes P0…Pk-1. The implementation of the
resourcerequest 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
10.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 YZ X YZ
P0 121 103
P1 201 012
P2 221 120
(A) P0
(B) P1
(C) P2
(D) None of the above, since the system is in a deadlock.
11. What are the four necessary conditions for deadlock to occur in a system? Explain.
13. All unsafe states may not lead to deadlock. “Why or why not”?
17. Consider a system with five processes P 0 through P 4 and have three resource types A, B, C.
Find out the number of instances of each resource type and retrieve the safe sequence.
MAX NEED AVAILABLE
A B C A B C A B C
P0 7 5 3 7 4 3 2 3 0
P1 3 2 2 0 2 0
P2 9 0 2 6 0 0
P3 2 2 2 0 1 1
P4 4 3 3 4 3 1
10. A system has 8 physical frames. There are 7 processes in the system of which 4 processes
have 2 pages each and 3 processes have 1 page each. The system uses inverted page table. Find
the total number of page table entries in the system. Justify your answer.
12. Consider a logical address space of eight pages of 1024 words each, mapped onto a physical
memory of 32 frames.
i) How many bits are there in the logical address?
ii) How many bits are there in the physical address?
13. What is TLB? Draw the diagram of paging hardware with TLB.
14. Given memory partitions of 100 kb, 500 kb, 200 kb and 600 kb ( in order ), how would each
of the first fit, best-fit and worst-fit algorithms place process of 212 kb, 417 kb, 112 kb and 426
kb ( in order) ? Which algorithm makes the most efficient use of memory?
16. What is fragmentation? Explain different types of fragmentation and their differences. Which
one may occur in paging system?
18. Consider a system with a 32-bit logical address space, a two-level paging scheme, 4 byte
page table entries, 1 KB pages and a 4 entry TLB. The page-table base register access time is 0
ns, TLB access time is 10 ns and memory access time is 100 ns.
a) How many address bits are needed for the page offset?
b) How much memory in bytes is required to store the outer page table entry in main
memory?
19. What are the two major differences between paging and segmentation?
Virtual Memory
1. Which of the following algorithm generally suffers from Belady’s anomaly
a) Optimal b) FIFO
c) LRU d) all of these.
3. Thrashing
a) Reduces page I/O b) Decreases the degree of multiprogramming
c) Implies excessive I/O d) Improves the system performance
6. Consider the following page reference string and a memory consisting of 4 frames:
1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6
Find the number of page faults considering
i) FIFO page replacement strategy
ii) LRU page replacement strategy.
Comment on the results obtained.
8. Consider the following sequence of memory references generated by a single process in a pure
paging system: 10 11 104 170 173 309 245 246 247 258 264. Determine the number of page
faults for each of the following page replacement algorithms assuming three (3) page frames are
available and all are initially empty. The size of a page is 100 words:
a) LRU b) FIFO c) Optimal page replacement
10. Having 3 physical memory frames show the behavior of LRU, FIFO and Optimal page
replacement algorithm for the page address string like 2, 3, 2, 1, 5, 2, 4, 5, 3, 2, 5, 2.
File Systems
1. What are the advantages and disadvantages of linked file Allocation Technique?
2. How does Indexed file Allocation Technique overcome the above disadvantages?
I/O Management
2. What is Direct Memory Access? How is it performed? What are its benefits?
Disk Management
1. Disk I/O is generally done in terms of
a) Sectors b) Bytes
c) Blocks d) Bits.
3. Which of the following RAID levels implements some form of parity calculations to introduce
redundancy?
a) RAID Level 2 b) RAID Level 4
c) RAID Level 6 d) All of these.
4. The time to move the disk arm to the desired cylinder in a hard disk is known as
a) Rotational latency b) Positioning time
c) Indexed d) Hashed.
7. What are the advantage of SCAN disk scheduling technique over circular SCAN disk
scheduling technique?
8. Explain the working of Shortest Seek Time First (SSTF) disk scheduling policy. What are its
advantages and disadvantages?
9. Suppose a disk drive has 300 cylinders, numbered 0 to 299. The current position of the desk
arm is 90. The queue of pending requests, in FIFO order is 36, 79, 15, 120, 199, 270, 89, 170.
Calculate the average movements for the following algorithms:
i) FCFS
ii) SSTF.
10. Explain the worst fit algorithm for memory management. What are its benefits?
13. Suppose a disk has size 128 GB, and blocks are of size 64 KB. If all block numbers are
sorted as 4-byte integers, how large must a main memory file-allocation table(FAT) be?
15. Draw the disk read/write head movement diagram for SSTF, SCAN, C-SCAN and FIFO, for
the track requests as 25, 75, 35, 100, 95, 175, 78, 125, 90, 35.
2. Explain any one technique adopted by operating systems for protection of objects in the
system.