808purl Operating-System TYS
808purl Operating-System TYS
808purl Operating-System TYS
PSUs
Workbook 2023
Detailed Explanations of
Try Yourself Questions
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
1 Introduction & Background of
Operating System
T1 : Solution
(d)
When a computer is switched on the operating system is loaded in RAM and its execution starts by
searching essential programs.
T2 : Solution
(b)
The process of loading the operating system into the memory of a PC is called booting.
T3 : Solution
(c)
Supervisory calls are privileged calls that are used to perform resource management functions, which are
controlled by OS.
T4 : Solution
(c)
We need a seperate program for compilation of programs that program is known as Compiler.
T5 : Solution
(c)
In a multiprogramming environment more than one process resides in the memory. They run in preemptive
mode. Either priority based or in time sharing mode.
www.madeeasypublications.org © Copyright
2 Processes and Threads
T1 : Solution
(c)
Medium-term scheduler is involved only in the decision for selection of partially serviced jobs.
T2 : Solution
(d)
Medium-term scheduler can transit a job from ‘ready’ to ‘suspended ready’.
If event occurs for suspend blocked job then which can move to ‘suspend ready’.
Medium term scheduler can transit a job from ‘suspend ready’ to ‘ready’.
∴ All given statements are correct.
T3 : Solution
(b)
Only the suspended processes and suspended blocked will reside in secondary memory. The processes
in the remaining states will reside in main memory.
T4 : Solution
(c)
Kernel is the set of primitive functions upon which the rest of the operating system functions are build up.
T5 : Solution
(c)
Swapping out the memory image of process A to the disk typically not performed by OS when switching
context from process A to B.
© Copyright www.madeeasypublications.org
4 Computer Science & IT • Operating System
T6 : Solution
(d)
T7 : Solution
(d)
When an interrupt occurs, an operating system may change the state of the interrupted process to “blocked”
and schedule another process.
T8 : Solution
(32)
When k = 5, 1 child process is created.
When k = 4, 2 child process are created (1 + 1).
When k = 3, 4 child process are created (2 + 2).
When k = 2, 8 child process are created (4 + 4).
When k = 1, 16 child process are created (8 + 8).
and 1 parent process.
Therefore total number of processes = 1 + 16 + 8 + 4 + 2 + 1 = 32
www.madeeasypublications.org © Copyright
3 CPU Scheduling
T1 : Solution
(b)
P1 P3 P4 P2
0 5 7 11 18
TAT1 = 5
TAT2 = 18
TAT3 = 7
TAT4 = 11
5 + 18 + 7 + 11 41
Average TAT = = = 10.25
4 4
T2 : Solution
(a)
S (n + 1) = α ⋅ T (n) + (1 – α) ⋅ S (n)
S (4) = 0.8 × T (3) + (1 – 0.8) × S(3)
= 0.8 × 4 + 0.2 × 5
= 3.2 + 1.0 = 4.2
© Copyright www.madeeasypublications.org
6 Computer Science & IT • Operating System
T3 : Solution
(d)
P1 P2 P3 P4 P5
P1 P2 P4 P5 P2
P1 P2 P3 P4 P5 P1 P2 P4 P5 P2
0 2 4 6 8 10 11 13 15 16 17
11 + 15 + 3 + 10 + 10 49
Average TAT = = = 9.8
4 4
T4 : Solution
(a)
T5 : Solution
(c)
FCFS: The process run in the order they arrived.
RR: Every process get a chance to execute.
SRTF: Minimizes the average waiting time.
Priority: Important processes get execute first.
www.madeeasypublications.org © Copyright
Detailed Explanations of Try Yourself Questions : GATE 2023 7
T6 : Solution
(7.2)
A.T E.T
A 0 6
B 3 2
C 5 4
D 7 6
E 10 3
Using SRTF:
A B A C E D
0 3 5 8 12 15 21
T.A.T (A) = 8 – 0 = 8
T.A.T (B) = 5 – 3 = 2
T.A.T (C) = 12 – 5 = 7
T.A.T (D) = 21 – 7 = 14
T.A.T (E) = 15 – 10 = 5
8 + 2 + 7 + 14 + 5
Average T.A.T = = 7.2
5
T7 : Solution
(1000)
I/O of process C
A B C A B C B C B C
0 50 100 150 200 250 300 350 400 450 500 1000
T8 : Solution
(12)
Periodic arrival times of T1 : 0, 3, 6, 9, 12, 15, 18, 21,...
1
Priority of T1 = , service time of T1 = 1.
3
© Copyright www.madeeasypublications.org
8 Computer Science & IT • Operating System
1
Priority of T2 = , service time of T2 = 2.
7
Periodic arrival times of T3 : 0, 20, 40,...
1
Priority of T3 = , service time of T3 = 4.
20
Preemption of T3
T1 T2 T1 T3 T1 T2 T1 T3
0 1 2 3 4 5 6 7 8 9 10 11 12
T9 : Solution
(8.25)
Gantt chart
P1 P2 P3 P2 P4 P1
0 3 7 8 10 13 20
www.madeeasypublications.org © Copyright
4 Process Synchronization
T1 : Solution
(b)
Process-3 depends on shared variable B. Initial value of A is 3. Process-1 can execute atmost three times
successfully P (A), then fourth time will be blocked. So V (B) is executed maximum 3 times. Now process-
3 can execute P (B) atmost 3 times successfully and fourth time it will be blocked. So process-3 prints “3”
maximum three times in the execution.
T2 : Solution
(a)
(i) A = 3, B = 0
First process-1 execute three times and process-1 is blocked (A = 0, B = 3).
(ii) Process-3 executes next three times and process-3 is blocked (A = 0, B = 0).
(iii) Process-2 executes last then it will be blocked by executing P (B) first time.
∴ No ‘1’ is printed by the execution of three processes and all are blocked.
Number of 1’s printed = 0
T3 : Solution
(c)
Mutual exclusion guaranteed but deadlock occurs.
(i) P1 executes P (S1) then preempts
(ii) P2 executes P (S2) then preempts
(iii) P3 executes P (S3) then preempts
(iv) P1 executes P (S2) then P1 blocked
(v) P2 executes P (S3) then P2 blocked
(vi) P3 executes P (S1) then P3 blocked
∴ Deadlock occurs.
© Copyright www.madeeasypublications.org
10 Computer Science & IT • Operating System
T4 : Solution
(d)
S1 = 0, S2 = 1, S3 = 0 ⇒ (0, 1, 0)
2 1 0 2 1 0 2 1 0 2 1
(0, 1, 0) (1, 0, 0) (0, 0, 1) same same same same same same same same
P3 ⇒ "2" P1 ⇒ "1" P1 ⇒ "0" as as as as as as as as
(1, 0, 0) (0, 0,1) (0, 1, 0) 1 2 3 1 2 3 1 2
T5 : Solution
(b)
T6 : Solution
(d)
P and Q can execute in any sequence therefore the string generated by two processes is (1+0)*.
T7 : Solution
(d)
Case-1: 1+ 0* that is any number of times P followed by Q any number of times.
Case-2: Alternate execution of P followed by Q every time (10)*.
Combining case 1 and 2 the string generated by two processes is (1+0* + (10)*)
T8 : Solution
(b)
All processes are in deadlock condition i.e., not even a single process can enter into critical section.
T9 : Solution
(10)
Everytime when process P10 enters it performs the ‘UP’ operation so after that one more process can enter
into it, so this phenomena continue till end.
So 10 processes at a time can enter into critical section.
www.madeeasypublications.org © Copyright
Detailed Explanations of Try Yourself Questions : GATE 2023 11
T10 : Solution
(c)
Consumer executes wait(S) then wait(n) and goes to sleep by decreasing n value.
After consumer sleep, producer goes to the sleep by executing wait(S).
T11 : Solution
(a)
It satisfies the mutual exclusion, so only one process can be in the critical section at any time.
T12 : Solution
(7)
S – 20 + 12 = –1
S – 8 = –1
S=–1+8 = +7
So, the initial values of the semaphore should be ‘7’.
© Copyright www.madeeasypublications.org
5 Deadlocks
T1 : Solution
(d)
(a) X = 40, Y = 20 ⇒ (P1, P2, P3, P4) = Need (25, 20, 20, 20)
Total resource units = 150
Currently allocated 45 + 40 + 40 + 20 = 145
⇒ Available = 5 units
No process can satisfy its need
(b) X = 50, Y = 10 ⇒ Need = (25, 20, 10, 30)
Current allocation = 45 + 40 + 50 + 10 = 145
Available = 5 units
⇒ No process can satisfy its need.
(c) X = 30, Y = 20
Allocation = (45, 40, 30, 20)
Need = (25, 20, 30, 20)
Available = 150 – (45 + 40 + 30 + 20) = 15
No process can satisfy its need.
(d) X = 20, Y = 30
Allocation = (45, 40, 20, 30)
Need = (25, 20, 40, 10)
Available = 150 – (45 + 40 + 20 + 30) = 15
P4 can satisfy its need
Available = 15 + 30 = 45
Now P1 or P2 or P3 can satisfy and they can finish in any order.
∴ Safe sequence exist for X = 20, Y = 30.
www.madeeasypublications.org © Copyright
Detailed Explanations of Try Yourself Questions : GATE 2023 13
T2 : Solution
(a)
Need
R1 R2 R3
P1 1 1 0
P2 1 0 0
P3 1 0 1
P4 1 1 0
P5 2 0 0
© Copyright www.madeeasypublications.org
6 Memory Management
T1 : Solution
(a)
In buddy system allocation ,the size of memory blocks allocated is in power of 2 (smallest sufficient to
service the memory allocation request).
Hence the first six allocations are 64 KB, 256 KB, 128 KB, 256 KB, 128 KB, 128 KB. This adds upto 960 KB
and hence the next request of 120 KB will not be allocated (the first request to fail).
T2 : Solution
(c)
16 KB = 214 bytes ⇒ 14 bit offset
211 * 211 * 211 * 214 = 247 bytes
11 11 11 14 ⇒ 3 levels
Level1 Level2 Level3 Offset
47
T3 : Solution
(d)
158 = 100 11110
Page 4 in frame 2 ⇒ 010 11110 (94)
53 = 001 10101
Page 1 in frame 7 ⇒ 111 10101 (245)
125 = 011 11101
Page 3 is invalid ⇒ Page fault
167 = 101 00111
Page 5 in frame 1 ⇒ 001 00111 (39)
www.madeeasypublications.org © Copyright
Detailed Explanations of Try Yourself Questions : GATE 2023 15
T4 : Solution
(d)
Link editor is another name of ‘linker’. Linker is a program which links the object code with it’s library.
T5 : Solution
(b)
Requests: 300, 25, 125, 50
50 150 300 350 600
First fit: 25 125 300 50
25 125 300 50
⇒ First fit can satisfy all the requests.
50 150 300 350 600
Best fit: 125 300 25
125 300 25
⇒ 50 can not be satisfied by best fit
© Copyright www.madeeasypublications.org
7 Virtual Memory
T1 : Solution
(1.76 × 10–4)
10–6 = (1 – F) 120 × 10–9 + F × 5 × 10–3
10–6 = (1 – F) 120 × 10–6 + 5000 F × 10–6
1 = 0.120 – 0.120 F + 5000 F
0.88 = –120 F + 5000 F
0.88 = 4999.88 F
F = 1.76 × 10–4
T2 : Solution
(c)
3 page frame
0 9 0 1 8 1 8 7 8 7 1 2 8 2 7 8 2 3 8 3
1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2
9 9 9 9 9 9 7 7 7 7 7 7 7 7 7 7 7 8 8
0 0 0 0 8 8 8 8 8 8 8 8 8 8 8 8 8 3 3 3
F F F F F F F F
FIFO = 8
Since FIFO is 8 so option (a) and (b) can be answer.
0 9 0 1 8 1 8 7 8 7 1 2 8 2 7 8 2 3 8 3
1 1 1 1 1 1 1 1 1 1 1 7 7 7 3 3 3
9 9 9 8 8 8 8 8 8 8 2 2 2 2 2 2 2 2 2
0 0 0 0 0 0 0 7 7 7 7 7 8 8 8 8 8 8 8 8
F F F F F F F F F
LRU = 9
So option (c) matching. No need of check for optimal algorithm same for (e) and (d) option.
www.madeeasypublications.org © Copyright
Detailed Explanations of Try Yourself Questions : GATE 2023 17
T3 : Solution
(c)
500 μsec = 150 ns × 0.9 + 0.1 × S
500 μsec = 0.150 μs × 0.9 + 0.1 × S
500 = 0.135 + 0.1 S
499.865 = 0.1 S
S = 4998.65 μsec = 4.99865 msec
T4 : Solution
(b)
Virtual memory fetch strategies determine when a page or segment should be moved from secondary
storage to main memory.
T5 : Solution
(a) r1, r2 ... rn – k + 1, ... rk, ... rn – 1, rn, rn, rn – 1, ... rk, ... rn – k + 1, rn – k, ... r2, r1
T6 : Solution
(16384)
Page table size = Number of entries × PTE size
228
4 × 2x = × 22
2x
2x + 2 = 230 – x ∵ 4 page frame
1 page frame = 2x
So, 4 page frame = 4.2 x
x+2 = 30 – x
2x = 28
x = 14
So, Page size = 2 x = 214 = 16384
T7 : Solution
(122)
Effective memory access time = 0.6 ∗ (10 + 80) + 0.4 ∗ (10 + 80 + 80) = 122
T8 : Solution
(6)
9 9 9 9 8 8 8 9 9 8
6 6 6 6 6 6 7 7
7 7 7 7 7 7 2 2 2
4 4 4 1 1 1 1 1 1 1
4 7 6 1 7 6 1 2 7 2
∴ 6 page faults will occur using LRU
© Copyright www.madeeasypublications.org
8 Disk Scheduling
T1 : Solution
(a)
Data cannot be written to secondary storage unless written within a file.
T2 : Solution
(d)
File attributes consist of name, type and identifier.
T3 : Solution
(3)
T4 : Solution
(99.60)
Overhead of each entry in FAT = 4 bytes
Block size = 103 bytes
Total size for each entry = 1004 bytes
100 × 106
Number of entries in FAT = = 0.099601
1004
www.madeeasypublications.org © Copyright
Detailed Explanations of Try Yourself Questions : GATE 2023 19
T5 : Solution
(10)
0 10 20 25 45 50 60 70 80 90 100
SSTF :
0 10 20 25 45 50 60 70 80 90 100
SCAN :
© Copyright www.madeeasypublications.org
9 File System
T1 : Solution
(b)
4983
= × 100 = 60.82%
8192
2. 24,576 – (8192 × 3) = 0%
3.2,328,432,002 – (8192 × 284232) = 3458
8192 – 3458 = 4734
4734
× 100 = 57.7%
8192
578
× 100 = 7.05%
8192
www.madeeasypublications.org © Copyright
Detailed Explanations of Try Yourself Questions : GATE 2023 21
T2 : Solution
(b)
Maximum possible size = [(Address pointed by doubly indirect block)2 + (Address pointed by single
address) + address points by single direct address] × [block size]
⎡⎛ 128 ⎞2 ⎛ 128 ⎞ ⎤
= ⎢⎜ ⎟ +⎜ ⎟ + 8 ⎥ × 128B
⎣⎝ 8 ⎠ ⎝ 8 ⎠ ⎦
= [28 + 24 + 23] × 128 B
= 32 KB + 2 KB + 1 KB = 35 KB
T3 : Solution
(c)
Data Block Size
= Number of DBA’s possible in one disk block.
DBA
© Copyright www.madeeasypublications.org