s-24-os soln
Q.1 (a) Define concurrency in OS and briefly explain its associated
challenges. (3 marks)
Answer:
Concurrency is the execution of multiple processes/threads in
overlapping time intervals, managed by the OS for efficient
resource utilization.
Challenges:
1. Race Conditions: Uncontrolled access to shared resources
leads to inconsistent results.
2. Deadlocks: Processes wait indefinitely for resources held by
others.
3. Starvation: Low-priority processes are denied resources.
4. Synchronization Overhead: Managing locks/semaphores
reduces performance.
Q.1 (b) Explain “5 State” process state transition diagram with an
illustration. (4 marks)
Answer:
States:
1. New: Process is created.
2. Ready: Process waits for CPU.
3. Running: Process executes on CPU.
4. Blocked: Process waits for I/O.
5. Terminated: Process finishes execution.
Transitions:
New → Ready: OS admits the process.
Ready → Running: CPU scheduler dispatches the process.
Running → Ready: Time quantum expires (preemption).
Running → Blocked: Process requests I/O.
Blocked → Ready: I/O completes.
Running → Terminated: Process exits.
Diagram:
Copy
Download
New
↓
Ready ↔ Running → Terminated
↓
Blocked
Q.1 (c) Discuss the variety of task types that the operating system
performs. (7 marks)
Answer:
1. Process Management:
o Creates, schedules, and terminates processes.
o Implements synchronization (semaphores, monitors).
2. Memory Management:
o Allocates/deallocates memory (paging, segmentation).
o Handles virtual memory.
3. File Management:
o Manages files/directories (create, delete, read/write).
4. Device Management:
o Controls I/O devices via drivers.
5. Security:
o Authenticates users, encrypts data.
6. Networking:
o Manages protocols (TCP/IP) and data transfer.
7. User Interface:
o Provides CLI (Terminal) or GUI (Windows).
Q.2 (a) Define the following terms: (3 marks)
i) Critical Section: A code segment accessing shared resources,
requiring mutual exclusion.
ii) Race Condition: Unpredictable results when processes access
shared data concurrently.
iii) Mutual Exclusion: Ensures only one process executes a critical
section at a time.
Q.2 (b) Differentiate Multiprocessing and Multithreading. (4
marks)
Multiprocessing Multithreading
Uses threads within a single
Uses multiple CPUs/cores.
process.
Multiprocessing Multithreading
Processes are isolated (no Threads share
shared memory). memory/resources.
Higher reliability (process Less reliable (thread crash can
crash ≠ system crash). terminate the process).
Example: Running Chrome Example: Multiple tabs in
and Photoshop together. Chrome.
Q.2 (c) Scheduling Algorithms (7 marks)
Option 1:
Processes:
Process Arrival Time Burst Time
A 0 3
B 1 6
C 4 4
D 6 2
i) FCFS:
Gantt Chart: A(0–3) → B(3–9) → C(9–13) → D(13–15)
Waiting Time:
o A: 0, B: 2 (3–1), C: 5 (9–4), D: 7 (13–6)
o Avg = (0 + 2 + 5 + 7)/4 = 3.5 ms
Turnaround Time:
o A: 3, B: 8 (9–1), C: 9 (13–4), D: 9 (15–6)
o Avg = (3 + 8 + 9 + 9)/4 = 7.25 ms
ii) Non-preemptive SJF:
Order: A(0–3) → D arrives at 6 but shortest burst is 2 → B(3–9) →
D(9–11) → C(11–15)
Waiting Time: A:0, B:2, C:7, D:3 → Avg = 3.0 ms
Turnaround Time: A:3, B:8, C:11, D:5 → Avg = 6.75 ms
iii) SRTN (Preemptive SJF):
Timeline:
A(0–1) → B(1–3) → A(3–4) → B(4–6) → C(6–10) → D(10–12)
→ B(12–15)
Waiting Time: A:1, B:9, C:2, D:4 → Avg = 4.0 ms
iv) Round Robin (Quantum=2):
Timeline:
A(0–2) → B(2–4) → A(4–5) → B(5–7) → C(7–9) → B(9–11) →
D(11–13) → C(13–15)
Waiting Time: A:2, B:9, C:5, D:5 → Avg = 5.25 ms
Option 2 (OR):
Processes:
Process Burst Time Priority
P1 10 3
Process Burst Time Priority
P2 1 1
P3 2 3
P4 1 4
P5 5 2
i) Preemptive SJF:
Order: P2(0–1) → P5(1–6) → P3(6–8) → P1(8–18) → P4(18–19)
Waiting Time: P1:8, P2:0, P3:4, P4:17, P5:0 → Avg =
(8+0+4+17+0)/5 = 5.8 ms
ii) Non-preemptive Priority:
Order: P2 (Priority 1) → P5 (2) → P1 (3) → P3 (3) → P4 (4)
Waiting Time: P1:10, P2:0, P3:11, P4:18, P5:1 → Avg = 8.0 ms
iii) Preemptive Priority:
Order: P2 → P5 → P1 (preempted by P3) → P3 → P1 → P4
Waiting Time: P1:15, P2:0, P3:0, P4:17, P5:0 → Avg = 6.4 ms
iv) Round Robin (Quantum=1):
Timeline:
P1(0–1), P2(1–2), P5(2–3), P3(3–4), P4(4–5), P1(5–6), P5(6–
7), P3(7–8), P1(8–9), P5(9–10), P1(10–18)
Waiting Time: P1:8, P2:0, P3:5, P4:0, P5:4 → Avg = 3.4 ms
Q.3 (a) Define and explain Message Passing. (3 marks)
Answer:
Message Passing is a mechanism for processes to communicate by
sending/receiving messages.
Methods:
1. Direct Communication: Processes explicitly name
sender/receiver (e.g., send(P, message)).
2. Indirect Communication: Uses mailboxes/ports.
Example: Chat applications using sockets.
Q.3 (b) Provide a brief description of the following: (4 marks)
i) Starvation: A process is denied resources indefinitely due to low
priority.
Solution: Aging (gradually increasing priority).
ii) Aging: Technique to prevent starvation by increasing priority of
waiting processes.
Q.3 (c) What is a scheduler? Illustrate queuing with an appropriate
diagram. (7 marks)
Answer:
Scheduler manages process execution order.
Types:
1. Long-term: Admits processes to the ready queue.
2. Short-term (CPU Scheduler): Selects processes for CPU.
3. Medium-term: Handles swapping.
Queuing Diagram:
Copy
Download
Long-term Scheduler
↓
Ready Queue ←→ CPU → I/O Queue
↑ ↓
Terminated ← I/O Completion
OR
Q.3 (a) Differentiate Semaphore and Monitor. (3 marks)
Semaphore Monitor
Integer variable High-level construct with built-
with wait() and signal(). in mutual exclusion.
Requires manual Automatically manages
synchronization. synchronization.
Example: Solving producer- Example: Java synchronized
consumer. methods.
Q.3 (b) Deadlock Prevention vs. Avoidance. (4 marks)
Prevention:
Breaks one of the four deadlock conditions (e.g., no hold-
and-wait).
Avoidance:
Uses Banker’s Algorithm to ensure safe states.
Q.3 (c) Describe Peterson's Algorithm. (7 marks)
Algorithm:
Copy
Download
// For two processes (i and j)
shared int turn;
shared boolean flag[2];
// Process i
flag[i] = true;
turn = j;
while (flag[j] && turn == j);
// Critical Section
flag[i] = false;
Explanation:
Ensures mutual exclusion using turn and flag variables.
Guarantees progress and bounded waiting.
Q.4 (a) Compare Multiprogramming with Fixed and Variable
Partitions. (3 marks)
Fixed Partitions Variable Partitions
Memory divided into fixed-sized Memory divided
blocks. dynamically.
Internal fragmentation. External fragmentation.
Fixed Partitions Variable Partitions
Simple to implement. Complex but flexible.
Q.4 (b) Authentication in OS Security. (4 marks)
Authentication verifies user identity using:
1. Passwords
2. Biometrics
3. Security tokens
OS Security: Limits unauthorized access via user permissions
and encryption.
Q.4 (c) RAID and Disk Scheduling (7 marks)
1. RAID Stripping:
Splits data across disks (e.g., RAID 0).
Example: Data blocks D1, D2, D3, D4 stored on disks Disk1,
Disk2, Disk1, Disk2.
2. Disk Scheduling (FCFS, SCAN, C-SCAN):
Given: Current head at 50, requests: 82, 170, 43, 140, 24, 16, 190
FCFS: 50 → 82 → 170 → 43 → 140 → 24 → 16 → 190
Total Distance: 32 + 88 + 127 + 97 + 116 + 8 + 174 = 642
cylinders
SCAN: 50 → 82 → 140 → 170 → 190 → 43 → 24 → 16
Total Distance: 32 + 58 + 30 + 20 + 147 + 19 + 8 = 314
cylinders
C-SCAN: 50 → 82 → 140 → 170 → 190 → 199 (end) → 0 →
16 → 24 → 43
Total Distance: 32 + 58 + 30 + 20 + 9 + 199 + 16 + 8 + 19
= 391 cylinders
OR
Q.4 (a) TLB (3 marks)
TLB (Translation Lookaside Buffer) is a hardware cache storing
recent page table entries to speed up virtual-to-physical address
translation.
Q.4 (b) Access Control List (4 marks)
ACL lists permissions for files/objects (e.g., user X: read/write, user
Y: read).
Q.4 (c) RAID Mirroring and Disk Scheduling (7 marks)
1. RAID Mirroring:
Duplicates data on two disks (RAID 1).
Example: Data D1 mirrored on Disk1 and Disk2.
2. Disk Scheduling (SSTF, LOOK, C-LOOK):
Given: Current head at 100, previous request at 81, requests:
55,58,39,18,90,160,150,38,184
SSTF: 100 → 90 → 58 → 55 → 39 → 38 → 18 → 150 → 160
→ 184
Total Distance: 10 + 32 + 3 + 16 + 1 + 20 + 132 + 10 + 24
= 248 cylinders
LOOK: 100 → 90 → 58 → 55 → 39 → 38 → 18 → 150 → 160
→ 184
Total Distance: Same as SSTF = 248 cylinders
C-LOOK: 100 → 150 → 160 → 184 → 18 → 38 → 39 → 55 →
58 → 90
Total Distance: 50 + 10 + 24 + 166 + 20 + 1 + 16 + 3 + 32
= 322 cylinders
Q.5 (a) Advantages and Disadvantages of Virtual Machines. (3
marks)
Advantages:
1. Isolation between VMs.
2. Runs multiple OS on one hardware.
Disadvantages:
3. Overhead due to hypervisor.
4. Complex resource management.
Q.5 (b) Shell Script (4 marks)
bash
Copy
Download
#!/bin/bash
echo "Executable files:"
find . -type f -executable
echo "Directories:"
find . -type d
echo "Zero-sized files:"
find . -type f -size 0
Q.5 (c) Page Replacement Algorithms (7 marks)
Reference String: 4, 7, 6, 1, 7, 6, 1, 2, 7, 2
Frames = 3
i) Optimal:
Page Faults: 4,7,6 (3) → 1 (replace 4) → 7 (hit) → 6 (hit) → 1 (hit)
→ 2 (replace 4) → 7 (hit) → 2 (hit)
Total Faults = 5
ii) FIFO:
Page Faults: 4,7,6 (3) → 1 (replace 4) → 7 (hit) → 6 (replace 7) → 1
(replace 6) → 2 (replace 1) → 7 (replace 2) → 2 (replace 7)
Total Faults = 7
iii) LRU:
Page Faults: 4,7,6 (3) → 1 (replace 4) → 7 (update) → 6 (update)
→ 1 (update) → 2 (replace 4) → 7 (replace 6) → 2 (replace 1)
Total Faults = 7
OR
Q.5 (a) Virtualization Diagram (3 marks)
Copy
Download
Host OS
↓
Hypervisor (e.g., VMware)
↓
+-----------------+
| VM1 | VM2 | VM3 |
+-----------------+
Q.5 (b) Advantages of Linux over Windows (4 marks)
1. Open-source and free.
2. Better security (fewer viruses).
3. Highly customizable (kernel modification).
4. Stable (less frequent crashes).
Q.5 (c) Memory Allocation Algorithms (7 marks)
Partitions: 100K, 500K, 200K, 300K, 600K
Processes: 212K, 417K, 112K, 426K
First-fit:
212K → 500K (Remaining: 288K)
417K → 600K (Remaining: 183K)
112K → 200K (Remaining: 88K)
426K: No suitable partition.
Best-fit:
212K → 300K (Remaining: 88K)
417K → 500K (Remaining: 83K)
112K → 200K (Remaining: 88K)
426K → 600K (Remaining: 174K)
Worst-fit:
212K → 600K (Remaining: 388K)
417K → 500K (Remaining: 83K)
112K → 388K (Remaining: 276K)
426K: No suitable partition.
Most Efficient: Best-fit (allocates all processes)