You are on page 1of 14

Operating

Systems
(Classroom Practice Booklet Solutions)

08. Ans: (b)


1. Process Management – I
Sol: In general, if no file name is specified in a
command, the shell takes as input that you
01. Ans: (c)
type on your keyboard.
02. Ans: (c)
09. Ans: (a)
03. Ans: (a) Sol: Have multiple processes in ready to run.
Sol: Software Interrupt is generated as a result of
10. Ans: (a)
execution of a privileged instruction. This
Sol: S.J.F is the optimal non-preemptive CPU
would change the mode from user to Kernel
scheduling algorithm.
& vice-versa. System calls, state changes
Explanation: SJF is the optimal non-
can be caused by program commands, which
preemptive CPU scheduling algorithm. So,
are referred to as system calls and are
in order to produce the optimal Solution
implemented using software interrupts or
here it considers the shortest job first. The
automatically following certain events.
optimal sequence is {j3, j2, j1}.
04. Ans: (d) Since, Burst time(j3) <Burst time(j2)< Burst
Sol: Loader is frequently required system time(j1)
software. But to start j3 CPU Should wait for 1.0 units
of time as its arrival time is 1.0.
05. Ans: (b)
Sol: Process going from running to ready state is 11. Ans: (b)
always preemptive. Sol: Each process runs for q period and if there
are n process p1 p2 p3..... pn p1 p2... then p1
06. Ans: (c)
turn comes again when it has completed
time quanta for remaining process p2 to pn
07. Ans: (c)
i.e., it would take at most (n–1)q time. So
Sol: Scheduler process is meant to decide which
Each process in round robin gets its turn
ready process next should run on CPU.
after <= (n–1)q time when we don't consider
ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata

: 2 : Operating Systems

overheads, but if we consider overhead(s) 15. Ans: (d) 16. Ans: (a)
then it would be ns+(n-1)q So, ns+(n-1)q 17. Ans: (b)
<= t overhead will be reduced when time Sol: Consider the each statement:
quantum is maximum allowable i.e., (i) Statement is false because there is no
q = (t–ns)/(n–1). connection between kernel supported
P1 Free P2 P3 P2 P1 P3 P1 P2 Free P2 threads and context switch.
0 1 2 3 5 6 8 9 10 11 14 15
(ii) Statement is true and it is drawback of
P1 I/O P2 I/O
P3 I/O user-level threads.
12. Ans: (b) (iii) Statement is true because kernel-
Sol: P1 → Finishing time = 10 supported threads having own memory
P2 → Finishing time = 15 area and scheduled independently by
P3 → Finishing time = 9 the OS.
(iv) Statement is false because kernel is
13. Ans: (b) unaware about user level threads and
Sol: Draw the Gantt Chart and observe the CPU there is no kernel support to user-level
idle times. threads.
Process Burst Time I/O Time CPU Time I/O Time
18. Ans: (b)
P1 10 2 7 1
Sol: The critical distinction between them is data
P2 20 4 14 2
P3 30 6 21 3 sharing processes do not share address space
without explicit assistance. Threads within a
Draw the Gantt chart and observe the CPU
process share address space.
idle time.
19. Ans: (c)
IDLE P1 P2 P3 IDLE
0 2 9 23 44 47 Sol: RR is a pre-emptive scheduler, which is
designed especially for time-sharing
% OF TIME CPU IS IDLE = 5/47 × 100
systems. In other words, it does not wait for
= 10.6
a process to finish or give up control. In RR,
each process is given a time slot to run.
14. Ans: (c)
If the process does not finish, it will “get
Sol: Hint: Draw the Gantt- Chart.
back in line” and receive another time slot
until it has completed.
ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata

: 3 : CSIT‐Postal Coaching Solutions

20. Ans: (b) (a) T/T S 


Because Q is more than T,
Sol: Total number of jobs executed per unit time (b) T/T S 
AftertimeT process blocks for I/O
(also called throughput)is maximum in SJF.
Since shorter jobs are executed first and (c) Since Q < T, Each run of T requires
More number of jobs will be executed per T/Q switches. The resultant overhead is
unit time. ST/Q.
 ST 
The efficiency = T T  
21. Ans: (c)
 Q 
Sol: The number of child processes with
Q
n-fork() is 2n –1 . 
QS
(d) Since Q = S from (c) replace Q by S
22. Ans: (b)
which is 50%.
23. Ans: (d) (e) The efficiency becomes 0 as Q is ready 0
Sol: Due to convoy effect.
30.
24. Ans: (d) Sol: (i) The SJF has the highest priority
(ii) The lowest level of Multilevel Feed
25. Ans: (d) back queue is FCFS.
Sol: Block initiated by process and Ready by OS. (iii)FCFS gives highest priority to the job
having been existence the longest time.
26. Ans: (b) 27. Ans: (a) (iv) None

28. 31.
Sol: The process will have increases it priority Sol: Run in the order
because of two pointers pointing same x, 3, 5, 6, if x < 3
process. The advantage is, it will be given else 3, x, 5, 6, if x > 3 & x < 5
more time but shorter processes will suffer. else 3, 5, x, 6 if x > 5 & x < 6
else 3, 5, 6, x if x > 6
29.
by applying SJF; as it generates the least
Sol: CPU efficiency
any waiting time.
= CPU useful time/ total CPU time.

ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata



: 4 : Operating Systems

There are only two main choices FCFS and Average waiting time
SJF as no priority and Quantum size etc. has 0  3  7  12 11
= = = 5.5
been given. Moreover x may take values 4 2

1,2,3,4,5, and more than that, it is assumed and so on.

that the job responses immediately after Thus, the order of execution depends on the

getting the CPU. Then response time will be value of x and average response time is

same as waiting time. SJF calculations are minimum x = 1.

shown by taking various values of x. SJF is


32.
considered because it produces minimum
Sol: Hint:Refer Process State Transition Diagram
response time.
33.
Case:1 x= 1
Sol: One is Zero and the other is the pid of the
Average waiting time = (0+1+4+9)/4
child process.
= 14/4 = 3.5
34.
x 3 5 6
Sol: Creates processes incessantly.
0 1 4 9 15
Case: 2 x = 2
2. Process Management – II
This job will again be the first job to be
executed. 01. Ans: (c)
Average waiting time = (0+2+5+10) / 4 Sol: Critical section implies usage of shared
= 17 / 4 = 4.25 resources.

Case: 3 x = 3. 02. Ans: (b)


Assuming x will again be the first job to be Sol: Since semaphore value S=10
executed. 6P  S = S – 6 = 4
Average waiting time = (0+3+6+11)/ 4 = 5 4V  S = S + 4 = 8

Case: 4 x = 4.
03. Ans: (b)
3 x 5 6 Sol: The semaphore value S = 7.
0 3 7 12 18 P operation will decrement the value of the
semaphore by 1.

ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata



: 5 : CSIT‐Postal Coaching Solutions

V operation will increment the value of the 06. Ans: (a)


semaphore by 1. Sol: When one process executes critical section
20P operations  S = S – 20 the other process waits up to shared variable
= 7 – 20 = – 13 Busy = False.
15V operations  S = S + 15
07. Ans: (c)
= – 13+15 = 2
Sol: If P1 access the variable critical_flag then it
04. Ans: (d) executes the critical section otherwise P2
Sol: This is the algorithm of solution of executes the critical section but both cannot
consumer produces process with the help of and there is a possible deadlock.
semaphore.
08. Ans: (d)
So, K = P (empty)  P for wait
Sol: Based on strict alternation.
L = V(full)  V for signal
M = P(full) 09. Ans: (c)
N = V(empty) Sol: (a) All philosophers gets one fork, each
philosopher waits for the other fork held
05. Ans: (d)
by other philosophers.
Sol: Sx and Sy are two binary semaphore if
(b) There is a deadlock.
assume P means wait or V means signal then
(c) This avoids deadlock.
for two process P1 and P2 we take alternate
then there is no chance of deadlock. 10. Ans: (b)
The code is as follows. Sol: If two barriers are invocated immediately
P1 P2 then two goes into deadlock.
while true do{ while true do{
L1 : P(Sx) L3 : P(Sx) 11. Ans: (b) 12. Ans: (c)

L2 : P(Sy) L4 : P(Sy)
13. Ans: (d)
x = x + 1; y = y + 1;
Sol: Fetch-And_Add( ) is stated as atomic.
y = y  1; x = y – 1;
Therefore, even if pre-emption takes place
V(Sx); V(Sy);
within the while loop, the other process will
V(Sy); V(Sx);
be denied the access to CS.
} }
ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata

: 6 : Operating Systems

14. Ans: (d) 19. Ans: (a)


Sol: X, W reads x and increment x by 1 Sol: The Program can be proved to demonstrate
Y, Z reads x and decrement by 2 that in any concurrent situation not more
start with X. will perform P(S) then S=1, than one process is allowed to enter CS.
read. Sometimes even no process is allowed after
x = 0, x = x + 1 = 1 one process enters and comes out of CS.
Then Y will perform P(S) then S = 0, read Hence at most one process in CS at any
x = 0, x = x–2 = –2, then store x. V(S), S = 1 time. The remaining all conditions can be
Then Z will perform P(S) then S = 0, read proved to be incorrect.
x = –2, x = x–2 = –4, then store x,V(S),S = 1
20. Ans: (a) 21. Ans: (c)
Then x will store x, V(S), S = 2, x = 1
Then W will perform P(S), S = 1, read x =1 22. Ans: (b) 23. Ans: 1 and 2
x = x + 1 = 2, store x, V(S), S = 2, x = 2
24.
15. Ans: (a) Sol: (a) Mutual exclusion is guaranteed
(b) Deadlock occurs; Allow both processes
16. Ans: (a) to get pre-empted after S2 & Q2
Sol: If context switching is disabled in P, and if respectively.
the value of semaphore is ‘one’, then it goes (c) Now mutual exclusion is not guaranteed
into infinite loop. Deadlock is not possible, as both the
processes would be executing the same
17. Ans: (a)
code.
18. Ans: (d)
25. (a) Ans: 3
Sol: As both processes can enter CS together
(b) Ans: 3
hence ME is violated. After the entry of both
(c) Ans: 0
processes into CS, on one process will
continuously enter the CS infinite times and
the other process would never be allowed to
enter the CS and the situation is like a
Livelock.[then option (d) is correct].

ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata



: 7 : CSIT‐Postal Coaching Solutions

08. Ans: (d)


3. Deadlocks
Sol: If there are 13 resources then deadlock will
not occur as the peak demands is also 13.
01. Ans: (c)
Sol: Only c is not a valid deadlock prevention 09. Ans: (b)
scheme. Sol: Right now (n-2) processes are blocked, as
available is zero. Only ‘p’ & ‘q’ processes
02. Ans: (a)
can complete, upon which they would
Sol: Deadlock prevention deals only with
release their resources xp, xq. therefore
preventing mutual exclusion, hold & wait,
if xp + xq ≥ min yk k ≠ p,q this would guarantee
No Preemption, Circular wait.
that one out of the blocked processes can
come out of the cycle. Right now (n–2)
03. Ans: (d)
processes are blocked, as available is zero.
04. Ans: (a) Only ‘p’ &’q’ processes can complete, upon
Sol: This is dead lock free but cause starvation. which they would release their resources Xp,
Xq therefore if Xp + Xq >= min Yk k != p, q this
05. Ans: (b)
would guarantee that one out of the blocked
Sol: If there are 5 processes then at least one
processes can come out of cycle.
process will get two tape drives out of six
tape drives. Hence the system is deadlock 10. Ans: (d) 11. Ans: (c)
free.
12. Ans: (a)
06. Ans: (c) Sol: Hint: Draw the timing diagram for all three
Sol: As there are 3 processes and 4 resources processes; one can observe that all the
then at least 1 process will get 2 resources. process requests could be satisfied at
Therefore, Deadlock will not occur. different intervals of time and eventually
leading to successful completion of them.
07. Ans: (a)
Sol: If there are 2 processes then each process 13. Ans: (b)
Sol: Deadlock is not possible, because there 3
will hold 3 tape drives as there are 6 tape
resources and 2 process, each needs a
drives for which the system is guaranteed to
maximum of two resources.
be deadlock free.
ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata

: 8 : Operating Systems

14. Ans: Yes 07. Ans: (c)


Sol: By definition of virtual memory.
15. (b) Ans: Need = Max-Allocation
(c) Ans: It is safe because the Needs of all 08. Ans: (b)
processes are satisfiable with the Sol: Virtual Memory is implemented on
available resources. secondary storage.
(d) Ans: Request should be granted only if
the resulting state of the system is safe 09. Ans: (c)

after granting the request. However if it Sol: Single level paging has overhead of large

is not then it is not granted and the page table sizes.

process initiating the request is blocked.


10. Ans: (c)
16. Ans: Run Safety Algorithm and check that Sol: due to Belady’s anomaly
the needs of all processes are satisfiable with Bélády's anomaly proves that it is possible
the available resources. to have more page faults when increasing
the number of page frames while using the
4. Memory Management First in First Out (FIFO) page replacement
algorithm.
01. Ans: (b) 02. Ans: (b)
11. Ans: (a)
03. Ans: (c)
Sol: Memory specification 12. Ans: (b)
= Number of words  width of word. Sol: Bélády's anomaly proves that it is possible
to have more page faults when increasing
04. Ans: (c) 05. Ans: (a)
the number of page frames while using the

06. Ans: (b) First in First Out (FIFO) page replacement

Sol: Initialized early means it is FCFS. algorithm.

If FIFO page replacement algorithm is used locality of reference, also known as the

then a memory page containing a heavily principle of locality, is the phenomenon of

used variable that was initialized very early the same value or related storage locations

and is in constant use is removed. being frequently accessed.

ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata



: 9 : CSIT‐Postal Coaching Solutions

13. Ans: (d) 18. Ans: (b)


Sol: At any time required 14KB A, B, and C or D
14. Ans: (a)
and E when you load it requires 14KB.
Sol: Dirty bit indicates whether page is clean or
modified 19. Ans: (c)

15. Ans: (a) 20. Ans: (a)&(b)


Sol: Segment table must be paged in order to be Sol: (a) Is false because memory references are
accommodated in one page. dynamically translated into physical
In a paged segmented scheme of memory address at runtime.
management, the segment table itself must (b) Is false, because all pieces of a process
have a page table because the segment table need not be loaded into main memory.
is often too large to fit in one page.
21. Ans: (d)
16. Ans: (b) Sol: Absolute addresses will be assigned only by
Sol: locality of reference, also known as the loader.
principle of locality, is the phenomenon of
22. Ans: (d)
the same value or related storage locations
Sol: EMAT
being frequently accessed. There are two
= 0.96[1ns + 0.9 (1 ns) + 0.1(1 ns+ 10 ns)]
basic types of reference locality. Temporal
+ 0.04[1 ns + 10 ns + 10 ns + 0.9 (1ns)
locality refers to the reuse of specific data
+0.1 (1ns+10ns)]
and/or resources within relatively small time
EMAT
durations. Spatial locality refers to the use of
=0.96[1ns+0.9(1ns)+0.1(1ns+10ns)]+0.04
data elements within relatively close storage
[1ns +10ns+10ns+0.9(1ns)+0.1(1ns+10ns]
locations. Sequential locality, a special case
TLB is successfully 96% of total request &
of spatial locality, occurs when data
for remaining 4%.
elements are arranged and accessed linearly,
RAM is accessed twice.
e.g., traversing the elements in a one-
So average time taken.
dimensional array.
= .96(1 +(0.9 #1) +0.1 #(1 +10))
17. Ans: (d) +.04(21 +(.9 #.1)) +0.1 #(1 +10)

ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata



: 10 : Operating Systems

= .96(1 +.9 +1.1) +0.4(21 +.09 +1.1) 27. Ans: (c)


= .96 #3 +0.4 #23 Sol: Find the reference string first the number of
= 2.88 +.92 page faults = length of reference string in
= 3.80, 4 ns this case as the number of frames is one.
Find the reference String first:
23. Ans: (c)
It is 1,2,4,5,1,2,3.
Sol: First level page table size = 4 Kb in the
The number of Page faults = length of
second level, we require 3 pages of the inner
reference string in this case as the number of
page table. One for the code, another for
frames is one.
data and last one for stack. A size of each
page is 4 KB; outer page table is also 4 KB. 28. Ans: (b) & (d)

24. Ans: (b) 29. Ans: (b)


Sol: a: True Sol: Page frame number is most important and
b: False virtual page number may not be stored
c: True entirely.
d: True
30. Ans: (c)
25. Ans: (b)
31. Ans: (b)
Sol: Virtual address = 32 bits
Sol: Linking is done at run-time in Dynamic
Physical address = 30 bits
Linking.
Page size = 4 K byte
Page table entry = 32 bits
32. Ans: (a) 33. Ans: (c)
VA 32
Number of pages = 2 12   2 20
2 Page size 34. Ans: (d)
Minimum number of bits
30 35. Ans(a)
=2 12  210  10 bits
2
Sol: The number of allocation units
= 1GB/64KB = 214.
26. Ans: (c)
1 bit is required for each allocation unit.

36. Ans: (c)

ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata



: 11 : CSIT‐Postal Coaching Solutions

37. Ans: (b) 46.


Sol: Effective Memory Access Time Sol: No. of entries equals no of pages. i.e., 32G
= p * (page fault service time)
47.
+ (1–p) *(Memory access time)
Sol: 3 Levels using the conventional formula of
 1    1 
=  6  * 10 * 106 ns + 1   6   * 20 ns page table size i.e N*e Bytes
 10    10  
= 30 ns (approximately) 48.
Sol: Using the equation EMAT = P*S+(1-P)*M
38.
Substituting the values from the statements
Sol: (a) 0, 4302 A: Error
(b) 1, 15 A: Error we get roughly in micro seconds.
(c) 2, 50 A: 90+50
49.
(d) 3, 400 A: Error
(e) 4, 112 A: Error Sol: Upon IO

39. Ans: (a) 40. Ans: (b) 50.


Sol: (a) 212 in 300 ; 417 in 500 ; 112 in 200 ;
41. Ans: (c) 42. Ans: (a) 350 in 600;
(b) Internal Frag. Is the difference of the
43.
Partition size and the accommodated
Sol: Physical address for the following logical
process size.
addresses = Base + logical address
(c) No External Fragmenetation in Fixed
(a) 219 + 430 = 649
Partitoning.
(b) 2300 + 10 = 2310
(c) 90 + 500 = 590 (Illegal reference). 51.
(d) 1327 + 400 = 1767 Sol: (a) 32 bits. P is 20 bits and D is 12 bits.
(e) 1952+112 = 2064 (Illegal reference) (b) 16
(c) 1M
44.
Sol: D, E; will 52. Ans: 32768
Sol: 64  512 B = 32768
45.
Sol: Good are A, C, E, F
ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata

: 12 : Operating Systems

53. Ans: 1 Byte Page Size PS = 8 K = 23.2 B = 213 B


Sol: Number of Partitions = 224/ 64K which is LAS 2 48
Number of pages    2 35
256 and hence addressed with a Byte. PA 213
2 32
54. Ans: 384 Number of frames   219
213
Sol: Page Table Size =  Number of pages  * PTE
 Page size  59.
Number of Pages = 2^40B/16KB (a) Ans: 400 (2*mmat)

PTE = 6B (b) Ans: 0.75*200 + 0.25*400 = 250 ns

2 40 B 60. Ans: 12 bits


 6B  384MB
16 KB
232
Sol: 20 = 12 bits
2
55.
Sol: (a) Minimum page size =128 Bytes. 61. Ans: (d) & (e)
Let page size = 2k Bytes
Page table size = 213 = (213-k)  2 bytes 5. File System & I/O Management

= 214-k Bytes
01. Ans: (b)
By given condition 214-k =2k, (k=7)
Sol: Nearest cylinder next is also known as
and hence page size = 27=128 Bytes.
shortest seek time first which is the optimal

56. algorithm.

219 *100 ns
Sol: = 51 approx 02. Ans: (b)
100 ms
Sol: To facilitate/minimize the Disk access time.

57. Ans: (a) 0


03. Ans: (d)
(b) 2
Sol: cache, memory and registers are not devices.
(c) 1
(d) 0 04. Ans: (a)
Sol: Large Block size results in more internal
58. Ans: (b)
fragmentation and reading a larger block
48
Sol: LAS = 2 B
results in reading more data and hence
PAS = 232 B
higher throughput.
ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata

: 13 : CSIT‐Postal Coaching Solutions

05. Ans: (a) 12.


Sol: Disk capacity = 16  128  256  512 B = 256Mb Sol: Data Transfer rate is measured in Bytes per
Sector address = 4 + 7 + 8 = 19 bits. second. It is the rate at which the number of
bytes that can be transferred in one second.
06. Ans: (a) 07. Ans: (c) It is calculated with reference to track size
and rpm.
08. Ans: (d) 09. Ans: (c) To read all 8 sectors in a double interleaved
disk two full rotations and latency of 0.5 is
10. Ans: (a) Transfer time is 204 ms
needed.
(b) Access time is 4 + 20 + 2014 ms
(c) Rot. Time is 40 ms 13.
(d) Time to read a sector 1/100 ms Sol: 64TB which is the sum of 12 direct pointers
(e) Time to read a track is 40 ms and size accessible with single double and
triple indirect pointers. Ignoring the sizes in
11. Ans: 3 front of triple indirect pointer the file size
Sol: 0 1 2 3 4 5 6 7 8 roughly is 64TB.
1 0 1 0 0 1 0 1 1 0 0 0 0 1 1 In use

0 0 0 1 1 0 0 0 0 1 0 1 1 0 1 Free

error error error

ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata

You might also like