0% found this document useful (0 votes)
22 views16 pages

OPERATING SYSTEM QUESTION BANK Answers

The document is a question bank on operating systems, covering definitions, short answers, and descriptive explanations related to key concepts. It includes topics such as process management, memory management, file systems, scheduling, and deadlock handling. The document serves as a study guide for understanding fundamental operating system principles and mechanisms.

Uploaded by

iamtahereditz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views16 pages

OPERATING SYSTEM QUESTION BANK Answers

The document is a question bank on operating systems, covering definitions, short answers, and descriptive explanations related to key concepts. It includes topics such as process management, memory management, file systems, scheduling, and deadlock handling. The document serves as a study guide for understanding fundamental operating system principles and mechanisms.

Uploaded by

iamtahereditz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

OPERATING SYSTEM QUESTION BANK

NOTE : Please refer textbook for best diagrams

2 Marks Questions (Definitions and Short Answer)

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.

4. List various operations on files.

• 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.

8. List any four characteristics of operating system.

• Multi-tasking

• Resource Management

• User Interface

• Security and Protection

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.

20. What does FIFO and MFU stand for?

• FIFO: First-In-First-Out

• MFU: Most Frequently Used

21. Define rollback. Rollback is the process of reverting a system or database back to a previous
consistent state.

3 Marks Questions (Short Notes)

1. Write a short note on Spooling.

SPOOL stands for Simultaneous Peripheral Operations Online.


It refers to a process where data is temporarily gathered and stored in a buffer (usually in secondary
storage like a disk) to be processed and used by devices like printers and disks later.

• 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:

o Increases system efficiency.

o Devices and CPUs can work independently without waiting.


2. Write a short note on Dining Philosopher’s Problem.

The Dining Philosophers Problem is a classical example of a synchronization problem.

• 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:

o Deadlock (if every philosopher picks up their left fork simultaneously).

o Starvation (a philosopher may never get both forks).

• Solutions:

o Allow philosophers to pick both forks at once.

o Limit the number of philosophers trying to eat at a time.

o Use a waiter (resource manager) to allow picking up forks.

3. Write a short note on Contiguous Memory Allocation.

Contiguous Memory Allocation is a memory management technique where each process occupies a
single continuous block of memory.

• Working:

o Memory is divided into fixed or variable-sized partitions.

o Each partition contains exactly one process.

• Advantages:

o Simple to implement and manage.

o Easy address calculation.

• Disadvantages:

o Leads to external fragmentation.

o Hard to allocate space for large processes if enough contiguous space isn't available.

4. Write a short note on Shortest Seek Time First (SSTF).

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).

o Always services the nearest track request.


• Advantages:

o Better performance than FCFS.

• Disadvantages:

o May cause starvation for far requests.

• Example:

o If head is at 53, and pending requests are 14, 37, 65, 67 → it will first move to 65
(closest).

5. Write a short note on Linked Allocation in File System.

Linked Allocation is a file allocation method where each file is a linked list of disk blocks.

• Working:

o Each block contains a pointer to the next block.

o The directory entry contains a pointer to the first block of the file.

• Advantages:

o No external fragmentation.

o Files can grow easily.

• Disadvantages:

o Slow direct access (must traverse from the beginning).

o Pointer overhead in every block.

• Diagram:

[Block1 | next->] → [Block2 | next->] → [Block3 | next-> NULL]

6. Write a short note on Address Binding in Memory Management.

Address Binding refers to the mapping of a program’s logical addresses to physical memory
addresses.

• Types:

o Compile-Time Binding: Logical addresses are bound to physical addresses at compile


time.

o Load-Time Binding: Binding happens when the program is loaded into memory.

o Execution-Time Binding: Binding is done during program execution (used for


processes that can move during execution).
• Importance:

o Allows efficient and flexible memory management.

7. Write a short note on Medium-term Scheduler.

The Medium-term Scheduler is responsible for temporarily removing (suspending) processes from
main memory and placing them into secondary storage (swap space).

• Purpose:

o To reduce the degree of multiprogramming.

o Free up memory for other processes.

• Operations:

o Suspends partially executed processes.

o Later resumes the process when memory is available.

• Example:

o A large process that is waiting for an event may be swapped out to improve system
performance.

8. Write a short note on Indexed Allocation.

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 directory entry points to the index block.

o The index block holds the addresses of all the file blocks.

• Advantages:

o Supports both sequential and direct access.

• Disadvantages:

o Overhead of index block.

• Diagram:

[Index Block] → [Data Block 1], [Data Block 2], [Data Block 3], ...

9. Write a short note on Solution for Critical Section Problem.

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:

o Software Algorithms: Peterson’s algorithm.

o Hardware Solutions: Test-and-set instructions.

o Synchronization Tools: Semaphores, Monitors.

4 Marks Questions (Short Descriptive)


1. Explain Operating System as a Manager of the Computer System.

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.

• Memory Manager: Allocates and deallocates memory spaces as needed by programs.

• Device Manager: Manages input/output devices via drivers.

• 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.

Feature Short Term Scheduler Medium Term Scheduler

Function Selects ready process for CPU Suspends and resumes processes from
execution. memory.

Frequency Runs very frequently (milliseconds). Runs less frequently.

Purpose Maximize CPU utilization. Reduce memory load (degree of


multiprogramming).
Example Choosing next process for CPU. Swapping out a large waiting process.

3. Draw and Explain Process Control Block (PCB).

PCB stores information about a process. It is created and maintained by the OS.

Contents of PCB:

• Process ID

• Process State (Ready, Running, etc.)

• CPU Registers

• Program Counter

• Memory Management Info

• Accounting Information

• I/O Status Information

Diagram:

+---------------------+

| Process ID |

+---------------------+

| Process State |

+---------------------+

| Program Counter |

+---------------------+

| CPU Registers |

+---------------------+

| Memory Info |

+---------------------+

| I/O Status |

+---------------------+

| Accounting Info |

+---------------------+
4. Compare Multiprogramming with Multiprocessing System.

Feature Multiprogramming Multiprocessing

Definition Multiple programs loaded into memory, CPU Multiple CPUs process multiple
switches between them. programs simultaneously.

Hardware Single CPU Multiple CPUs

Purpose Better CPU utilization High performance and parallelism

Example Mainframe Systems Modern servers with multiple


processors

5. Draw and Explain Process State Diagram.

Diagram:

New → Ready → Running → Terminated

↘ Blocked ↗

States:

• New: Process is being created.

• Ready: Waiting to be assigned to a CPU.

• Running: Instructions are being executed.

• Blocked: Waiting for some event (like I/O).

• Terminated: Process has finished execution.

6. Compare Internal and External Fragmentation.

Feature Internal Fragmentation External Fragmentation

Occurs Allocated memory may have unused Free memory is scattered, but not
When space inside a partition. enough contiguous space.

Example Fixed partitioning wastes space. Variable-sized allocation leads to small


gaps.

Solution Better partition sizing. Compaction or paging.

7. Explain Semaphores and their Types.

Semaphore is a synchronization tool used to control access to shared resources.

• Types:

o Binary Semaphore: Values are 0 or 1; acts like a lock.


o Counting Semaphore: Values range over an unrestricted domain; used for multiple
instances of resources.

Operations:

• wait() (P): Decrement the semaphore. Block if value < 0.

• signal() (V): Increment the semaphore. Wake up a waiting process.

8. What is Deadlock? Explain Deadlock Handling Techniques.

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.

• Deadlock Recovery: Kill processes or rollback to recover.


Deadlock Recovery: Kill processes or rollback to recover.

9. Explain Different Types of Directory Structure.

Different directory structures are:

• Single-Level Directory:

o All files in one directory.

o Simple but can cause naming conflicts.

• Two-Level Directory:

o Separate directory for each user.

o No filename conflict between users.

• Tree-Structured Directory:

o Directory contains files and subdirectories.

o Hierarchical, easy to group related files.

• Acyclic Graph Directory:

o Files/directories can be shared across directories.

o No cycles allowed (no looping back).

• General Graph Directory:

o Similar to acyclic, but cycles are allowed.


o Needs careful cycle detection.

Diagram for Tree Directory:

Root

├── User1
│ ├── file1
│ └── file2
└── User2
└── file3

10. Explain Linked Allocation in File System.

• Linked Allocation:

o Each file is a linked list of disk blocks.

o Blocks may be scattered anywhere on the disk.

o Each block contains data + pointer to the next block.

Advantages:

• No external fragmentation.

• Easy to grow files dynamically.

Disadvantages:

• Sequential access only (slow random access).

• Extra space for pointers.

Diagram:

[Block1 | Pointer] -> [Block2 | Pointer] -> [Block3 | NULL]

11. Compare Paging and Segmentation.

Feature Paging Segmentation

Memory Division Fixed-size pages Variable-size segments

External Fragmentation No Yes

Logical View Not visible to user Visible to user (functions, arrays)

Access Time Faster May be slower

Example 4KB Pages Code segment, Stack segment


12. Explain File Structure with Diagram.

File Structure refers to how data is organized inside a file.

Types:

• Byte Sequence: File is just a sequence of bytes.

• Record Sequence: File contains fixed or variable-length records.

• Tree Structure: Data organized like a tree (databases).

Diagram:

File

├── Record 1
├── Record 2
└── Record 3

13. Explain Memory Management through Fragmentation with Diagram.

• Internal Fragmentation: Wasted space inside allocated memory.

• External Fragmentation: Enough total memory, but scattered.

Memory Diagram:

+--------+-----+---------+-----+

| Process| Hole| Process | Hole|

+--------+-----+---------+-----+

Solutions:

• Compaction: Shift processes to one side to make space.

• Paging/Segmentation: Logical memory division.

14. Explain Types of Deadlock Conditions and Solutions.

Deadlock Conditions:

1. Mutual Exclusion: Only one process can use resource.

2. Hold and Wait: Holding one resource while waiting for others.

3. No Preemption: Cannot forcibly remove resource.

4. Circular Wait: Circular chain of processes waiting.

Solutions:

• Prevention: Eliminate any one condition.


• Avoidance: Safe state checks (Banker's Algorithm).

• Detection: Find cycles in Resource Allocation Graph.

• Recovery: Kill processes or rollback.

15. Explain Job Control Block (JCB) with Diagram.

• JCB: Contains information about a job being managed by OS.

Fields in JCB:

• Job ID

• Priority

• Memory Requirements

• I/O Requests

• Job Status

Diagram:

+------------------+

| Job ID |

+------------------+

| Priority |

+------------------+

| Memory Needs |

+------------------+

| I/O Requirements |

+------------------+

| Status |

+------------------+

16. Explain Critical Section Problem.

• Critical Section: Section where a process accesses shared resources.

• Problem: Two or more processes accessing shared data must not conflict.

Solution Requirements:

• Mutual Exclusion: Only one process in critical section.

• Progress: No process waits forever.


• Bounded Waiting: Limit on how long a process waits.

Methods:

• Locks

• Semaphores

• Monitors

17. Explain Various Page Replacement Algorithms (FIFO, Optimal, LRU).

Page Replacement Algorithms decide which memory page to replace when a new page comes and
memory is full.

• FIFO (First-In-First-Out):

o Oldest loaded page is replaced first.

o Simple but not always optimal.

Example:

Pages: 1 2 3 4 1 2 5

Replacement order: 1 -> 2 -> 3 -> 4...

• Optimal Page Replacement:

o Replace the page that will not be used for the longest time in future.

o Gives minimum page faults but is theoretical (needs future knowledge).

• LRU (Least Recently Used):

o Replace the page that was used least recently.

o Good approximation of optimal.

Comparison Table:

Algorithm Principle Pros Cons

FIFO Oldest first Simple Poor performance sometimes

Optimal Furthest future use Best possible Not implementable directly

LRU Least recent use Efficient Needs tracking history

18. Explain System Calls related to Process and Job Control.

System Calls allow user programs to request services from OS.

Process Control System Calls:

• fork(): Create a new process.


• exec(): Replace process memory with a new program.

• wait(): Wait for a child process to finish.

• exit(): Terminate a process.

• getpid(): Get process ID.

• kill(): Send a signal to a process.

Job Control System Calls:

• submit(): Submit jobs for execution (batch systems).

• hold(): Pause execution.

• release(): Resume execution.

19. Explain Multilevel Feedback Queue Scheduling.

Multilevel Feedback Queue (MLFQ):

• Multiple queues with different priorities.

• A process can move between queues based on its behavior.

Features:

• Separate queues for short and long jobs.

• Aging: Prevents starvation.

• If a process uses too much CPU time → move to a lower priority queue.

Diagram:

Queue 1 (Highest priority) - Short Quantum

Queue 2 - Medium Quantum

Queue 3 (Lowest priority) - Long Quantum

20. Explain Dining Philosopher Synchronization Problem.

Dining Philosophers Problem:

• Five philosophers sit around a table.

• Each philosopher needs two forks to eat.

• Forks are shared between neighboring philosophers.

Problems:

• Deadlock: Each philosopher picks one fork, waiting forever.

• Starvation: A philosopher may never get both forks.


Solutions:

• Pick up both forks together (atomic action).

• Allow at most 4 philosophers to sit at the table at once.

• Asymmetrical solution: Odd philosopher picks left fork first, even philosopher picks right fork
first.

21. Explain Free Space Management (Bit Vector, Grouping).

Free Space Management methods track free disk blocks.

• Bit Vector:

o One bit per block (0 = free, 1 = occupied).

Example:

Blocks: [0][1][0][1][0] → Free blocks: 0, 2, 4

• Grouping:

o Store addresses of free blocks in a list.

o First free block points to next free block group.

Comparison:

Method Advantage Disadvantage

Bit Vector Easy to find free blocks Needs lots of memory

Grouping Efficient use of space Searching takes time

22. Explain Resource Allocation Graph in Deadlock Detection.

• Resource Allocation Graph (RAG):

o A directed graph where:

▪ Processes = circles

▪ Resources = squares

▪ Edges:

▪ Request Edge: Process → Resource

▪ Assignment Edge: Resource → Process

Deadlock Detection:

• Cycle in RAG ⇒ Deadlock exists.


Simple Diagram:

P1 → R1 → P2 → R2 → P1 (Cycle → Deadlock)

23. Differentiate Preemptive and Non-Preemptive Scheduling.

Aspect Preemptive Scheduling Non-Preemptive Scheduling

Control OS can interrupt a process Process runs until it completes

Example Round Robin, Priority Scheduling FCFS, SJF (non-preemptive)

Responsiveness Better for interactive systems Better for batch systems

Overhead Higher (context switches) Lower (fewer switches)

Starvation Possibility Yes Less likely

You might also like