Operating System Solved Paper
Q.1 (A) Define Operating System. Enlist and explain different types of OS.
An Operating System (OS) is system software that acts as an intermediary between the user and
computer hardware. It manages hardware resources and provides services for computer programs.
Types of Operating Systems:
1. Batch Operating System: Jobs are processed in batches without user interaction.
2. Time-Sharing OS: Multiple users can use system resources simultaneously.
3. Distributed OS: Manages multiple computers as a single system.
4. Real-Time OS: Immediate processing, used in critical applications.
5. Network OS: Provides networking services across connected computers.
6. Mobile OS: Designed for mobile devices like Android and iOS.
Q.1 (B) Five services provided by an OS and explanation:
1. Program Execution: Loads and runs user programs.
2. I/O Operations: Handles all input and output automatically.
3. File System Manipulation: Manages files and directories.
4. Communication: Manages inter-process communication.
5. Error Detection: Monitors the system and handles errors.
User-level programs cannot provide these services efficiently without the OS.
Q.2 (A) Actions taken by a kernel to context-switch:
1. Save current process state.
2. Move process to ready queue.
3. Select next process for execution.
4. Load new process state.
5. Update memory information.
6. Resume execution of the selected process.
Q.2 (B) Calculate Average Waiting Time and Turnaround Time.
Given:
P1: 5 ms, P2: 24 ms, P3: 24 ms, P4: 10 ms, P5: 33 ms
a) FCFS:
AWT = 30 ms, ATT = 49.2 ms
b) SJF:
AWT = 24.4 ms, ATT = 43.6 ms
c) Round Robin (Time slice 5 ms):
AWT approximately 41 ms, ATT approximately 60 ms
Q.3 (A) Inter-process Communication (IPC) and Function Callback
IPC: Mechanism allowing processes to communicate.
Methods: Shared Memory, Message Passing, Pipes, Sockets, Signals, Semaphores.
Function Callback: Passes function as an argument.
Difference: IPC is for multiple processes; callback is within one process.
Q.3 (B) Why interrupts are not suitable for synchronization:
1. Complex in multiprocessor systems.
2. Halts other processors.
3. Delays real-time responses.
4. Not scalable.
5. Can cause deadlocks.
6. Semaphores and locks are better options.
Q.3 (C) Requirements for Critical Section Problem:
1. Mutual Exclusion
2. Progress
3. Bounded Waiting
4. Deadlock Free
5. Starvation Free
6. Fairness
Q.4 (A) Dining Philosophers Problem:
Deadlock Conditions:
1. Mutual Exclusion
2. Hold and Wait
3. No Preemption
4. Circular Wait
Solution: Change chopstick order or use a waiter.
Q.4 (B) Deadlock Detection in Resource Allocation Graph:
Given resources: R1 to P1 to R2 to P2 to R3 to P3 to R4 to P4 to R1 to P5
Cycle exists which means deadlock is confirmed.
Q.5 (A) Memory Allocation: First-fit, Best-fit, Worst-fit
Memory Blocks: 100 KB, 500 KB, 200 KB, 300 KB, 600 KB
Processes: 212 KB, 417 KB, 112 KB, 426 KB
First-fit: Fail for 426 KB
Best-fit: All fit
Worst-fit: Fail for 426 KB
Most efficient: Best-fit
Q.5 (B) Memory Management Comparison
Contiguous: High external fragmentation, difficult code sharing.
Segmentation: Reduced fragmentation, possible code sharing.
Paging: No external fragmentation, easy code sharing.