OPERATING SYSTEM QUESTION BANK Answers
OPERATING SYSTEM QUESTION BANK Answers
1. Define process. A process is a program in execution. It consists of the program code, current
activity, stack, data section, and heap.
2. What is context switch? Context switch is the process of storing the state of a currently running
process so that it can be resumed later and switching the CPU to another process.
3. What is page frame? A page frame is a fixed-length contiguous block of physical memory into
which pages are mapped in memory management.
• Create
• Open
• Read
• Write
• Close
• Delete
5. What is rotational latency in disk scheduling? Rotational latency is the delay waiting for the disk
to rotate to the correct sector under the read-write head.
6. Define critical section. A critical section is a part of a program where the shared resource is
accessed and which must not be executed by more than one process at a time.
7. State Belady’s anomaly. Belady’s anomaly refers to the counter-intuitive situation where
increasing the number of page frames results in an increase in the number of page faults.
• Multi-tasking
• Resource Management
• User Interface
9. Define deadlock. Deadlock is a situation where a group of processes are blocked because each
process is holding a resource and waiting for another resource held by another process.
10. What is role of operating system? The operating system acts as an intermediary between users
and hardware, managing resources and providing services.
11. What is least recently used in memory management? Least Recently Used (LRU) is a page
replacement algorithm that replaces the page that has not been used for the longest time.
12. Define seek time. Seek time is the time taken by the disk’s read/write head to move to the track
where the data is stored.
13. What is compaction? Compaction is the process of combining all free memory space together to
create a large block of free memory.
14. What is starvation? Starvation occurs when a process waits indefinitely to acquire a resource
due to continuous allocation to other processes.
15. Define safe state. A system is in a safe state if there is a safe sequence of processes such that
each can complete without causing a deadlock.
16. What is fragmentation? Fragmentation is the condition where memory space is wasted because
the total memory is enough but not contiguous.
17. Define system program. System programs provide a convenient environment for program
development and execution. Examples include compilers, assemblers, and editors.
18. What is turnaround time? Turnaround time is the total time taken from the submission of a
process to its completion.
19. What is demand paging? Demand paging is a memory management scheme where pages are
loaded into memory only when they are needed.
• FIFO: First-In-First-Out
21. Define rollback. Rollback is the process of reverting a system or database back to a previous
consistent state.
• Working: Instead of sending data directly to the printer (or any slow device), the data is
stored in the spool (queue) and the device accesses it at its speed.
• Example: Multiple print jobs from different users are stored in a disk queue and the printer
prints them one by one.
• Advantages:
• Problem Statement: Five philosophers sit at a round table with one fork between each pair.
Each philosopher must alternately think and eat. Eating requires two forks (left and right).
• Challenges:
• Solutions:
Contiguous Memory Allocation is a memory management technique where each process occupies a
single continuous block of memory.
• Working:
• Advantages:
• Disadvantages:
o Hard to allocate space for large processes if enough contiguous space isn't available.
Shortest Seek Time First (SSTF) is a disk scheduling algorithm that selects the disk I/O request that is
closest to the current head position.
• Working:
o It reduces the seek time compared to FCFS (First Come First Serve).
• Disadvantages:
• Example:
o If head is at 53, and pending requests are 14, 37, 65, 67 → it will first move to 65
(closest).
Linked Allocation is a file allocation method where each file is a linked list of disk blocks.
• Working:
o The directory entry contains a pointer to the first block of the file.
• Advantages:
o No external fragmentation.
• Disadvantages:
• Diagram:
Address Binding refers to the mapping of a program’s logical addresses to physical memory
addresses.
• Types:
o Load-Time Binding: Binding happens when the program is loaded into memory.
The Medium-term Scheduler is responsible for temporarily removing (suspending) processes from
main memory and placing them into secondary storage (swap space).
• Purpose:
• Operations:
• Example:
o A large process that is waiting for an event may be swapped out to improve system
performance.
Indexed Allocation is a method where a special block known as the index block contains all the
pointers to the actual data blocks of the file.
• Working:
o The index block holds the addresses of all the file blocks.
• Advantages:
• Disadvantages:
• Diagram:
[Index Block] → [Data Block 1], [Data Block 2], [Data Block 3], ...
The Critical Section Problem arises when multiple processes access shared resources
simultaneously.
• Conditions for Solution (must satisfy):
o Mutual Exclusion: Only one process can enter the critical section at a time.
o Progress: If no process is in the critical section, the next process can enter without
unnecessary delay.
o Bounded Waiting: A process must enter its critical section after a bounded number
of entries by other processes.
• Solutions:
The Operating System (OS) acts as a manager for the entire computer system. It manages hardware,
software, and system resources efficiently.
Roles as Manager:
• Resource Manager: Controls and allocates CPU time, memory space, disk storage, and I/O
devices.
• Process Manager: Manages processes including their creation, scheduling, and termination.
• File Manager: Handles the storage, retrieval, and updating of data files.
• Security and Access Manager: Protects system resources and ensures user authentication.
Thus, OS works like a manager ensuring smooth operation, resource sharing, and preventing
conflicts
2. What is scheduling? Compare Short Term Scheduler and Medium Term Scheduler.
Scheduling refers to the process of selecting which process should run at any given time.
Function Selects ready process for CPU Suspends and resumes processes from
execution. memory.
PCB stores information about a process. It is created and maintained by the OS.
Contents of PCB:
• Process ID
• CPU Registers
• Program Counter
• Accounting Information
Diagram:
+---------------------+
| Process ID |
+---------------------+
| Process State |
+---------------------+
| Program Counter |
+---------------------+
| CPU Registers |
+---------------------+
| Memory Info |
+---------------------+
| I/O Status |
+---------------------+
| Accounting Info |
+---------------------+
4. Compare Multiprogramming with Multiprocessing System.
Definition Multiple programs loaded into memory, CPU Multiple CPUs process multiple
switches between them. programs simultaneously.
Diagram:
↘ Blocked ↗
States:
Occurs Allocated memory may have unused Free memory is scattered, but not
When space inside a partition. enough contiguous space.
• Types:
Operations:
Deadlock occurs when a set of processes are blocked because each process is holding a resource and
waiting for another.
Handling Techniques:
• Deadlock Prevention: Ensure at least one necessary condition does not hold.
• Deadlock Avoidance: Use algorithms like Banker's Algorithm to avoid unsafe states.
• Deadlock Detection: Allow deadlocks and detect them using Resource Allocation Graph.
• Single-Level Directory:
• Two-Level Directory:
• Tree-Structured Directory:
Root
│
├── User1
│ ├── file1
│ └── file2
└── User2
└── file3
• Linked Allocation:
Advantages:
• No external fragmentation.
Disadvantages:
Diagram:
Types:
Diagram:
File
│
├── Record 1
├── Record 2
└── Record 3
Memory Diagram:
+--------+-----+---------+-----+
+--------+-----+---------+-----+
Solutions:
Deadlock Conditions:
2. Hold and Wait: Holding one resource while waiting for others.
Solutions:
Fields in JCB:
• Job ID
• Priority
• Memory Requirements
• I/O Requests
• Job Status
Diagram:
+------------------+
| Job ID |
+------------------+
| Priority |
+------------------+
| Memory Needs |
+------------------+
| I/O Requirements |
+------------------+
| Status |
+------------------+
• Problem: Two or more processes accessing shared data must not conflict.
Solution Requirements:
Methods:
• Locks
• Semaphores
• Monitors
Page Replacement Algorithms decide which memory page to replace when a new page comes and
memory is full.
• FIFO (First-In-First-Out):
Example:
Pages: 1 2 3 4 1 2 5
o Replace the page that will not be used for the longest time in future.
Comparison Table:
Features:
• If a process uses too much CPU time → move to a lower priority queue.
Diagram:
Problems:
• Asymmetrical solution: Odd philosopher picks left fork first, even philosopher picks right fork
first.
• Bit Vector:
Example:
• Grouping:
Comparison:
▪ Processes = circles
▪ Resources = squares
▪ Edges:
Deadlock Detection:
P1 → R1 → P2 → R2 → P1 (Cycle → Deadlock)