Operating System – Question Bank
(Detailed Answers)
1. Describe the content of Process Control Block (PCB)?
A Process Control Block (PCB) is a data structure used by the operating system to store all
information about a process.
Contents include:
- Process ID
- Process State (new, ready, running, waiting, terminated)
- Program Counter
- CPU Registers
- Memory Management Info (base & limit registers)
- Accounting Information (CPU usage, time limits)
- I/O Status Info (list of I/O devices allocated).
2. What is Deadlock? Explain Circular Wait and Mutual Exclusion with
neat diagram.
A Deadlock is a state in which a set of processes are blocked because each process is holding
a resource and waiting for another.
**Conditions for Deadlock:**
1. Mutual Exclusion
2. Hold and Wait
3. No Preemption
4. Circular Wait
- **Mutual Exclusion**: At least one resource must be held in a non-shareable mode.
- **Circular Wait**: A set of processes are waiting for each other in a circular form.
Diagram:
P1 → R1 → P2 → R2 → P1 (cycle)
3. Differentiate between Preemptive and Non-preemptive Scheduling.
**Preemptive Scheduling:**
- The process can be interrupted.
- Better for interactive systems.
- Example: Round Robin, SRTF.
**Non-preemptive Scheduling:**
- A process runs until it completes or blocks.
- Simpler to implement.
- Example: FCFS, SJF (non-preemptive).
4. What is system call with neat diagram? Explain any two system call.
System calls provide the interface between a process and the OS. Types include:
1. **Process Control**: fork(), exit()
2. **File Management**: open(), read(), write()
3. **Device Management**: ioctl(), read(), write()
4. **Information Maintenance**: getpid(), alarm()
5. **Communication**: pipe(), shmget()
Diagram:
User Mode → Trap → Kernel Mode → System Call → Return to User
5. Explain the Process Control Block with neat diagram.
Same as Q1 – additionally, diagram:
```
+----------------------+
| Process ID (PID) |
| State |
| Program Counter |
| CPU Registers |
| Memory Info |
| I/O Info |
+----------------------+
```
Each running process has its own PCB managed by the OS.
6. Explain the concept of context switch and Mutual Exclusion?
**Context Switch**: The process of saving the state of a running process and loading the
state of the next process.
Includes saving:
- Program counter
- Registers
- Stack pointer
**Mutual Exclusion**: A technique to prevent race conditions by ensuring only one process
accesses a critical section at a time. Achieved via semaphores, mutexes, monitors etc.
7. State and explain Multithreading models with neat diagram?
Multithreading allows multiple threads in a process to execute concurrently.
**Models:**
1. **Many-to-One**: Many user-level threads mapped to one kernel thread. Efficient but no
true concurrency.
2. **One-to-One**: Each user thread maps to a kernel thread. More concurrency but heavier.
3. **Many-to-Many**: Many user threads mapped to many kernel threads. Good balance.
Diagram:
```
User Threads → Kernel Threads
[1→1], [M→1], [M→M]
```
11. Explain Multilevel Queue Scheduling (MQL).
MQL divides processes into multiple queues based on priority/type (foreground,
background). Each queue has its own scheduling algorithm.
Example Queues:
- System Processes (Highest priority)
- Interactive Processes
- Batch Processes
CPU is assigned to highest priority queue. Lower queues only run when higher are empty.
12. Explain Multilevel Feedback-Queue Scheduling (MFQS).
MFQS allows processes to move between queues based on behavior and age.
Characteristics:
- Multiple queues with different priorities and algorithms.
- Aging and feedback move processes.
- High priority short jobs are finished fast.
It improves fairness and response time.
Example: Round Robin in top queues, FCFS in lowest.