OS Questions
OS Questions
Answer: Virtual memory is a memory management technique where the operating system uses both
hardware and software to allow a computer to compensate for physical memory shortages by temporarily
transferring data from random access memory (RAM) to disk storage.
Follow-up:
How does virtual memory improve system performance?
What are the advantages and disadvantages of virtual memory?
Explain demand paging and page replacement algorithms used in virtual memory.
Answer: Segmentation and paging are memory management techniques used in operating systems.
Segmentation divides memory into logical segments while paging divides memory into fixed-size pages.
Follow-up:
What are the differences between segmentation and paging?
How do segmentation and paging contribute to memory protection and sharing?
Can segmentation and paging be used together? If yes, how?
3. Explain Deadlocks:
Answer: A deadlock occurs in a system when two or more processes are unable to proceed because
each is waiting for the other to release a resource.
Follow-up:
What are the necessary conditions for a deadlock to occur?
How can deadlocks be detected and resolved?
Explain the various strategies for deadlock prevention.
Answer: Semaphores and locks are synchronization primitives used to control access to shared
resources in a concurrent system. Semaphores can be used to control access to a resource with a
counter, while locks provide exclusive access to a resource.
Follow-up:
What are the differences between binary semaphores and counting semaphores?
Explain how deadlock can occur with locks and semaphores and how it can be prevented.
Compare and contrast semaphores and monitors.
Answer: Synchronization techniques are used to coordinate the execution of multiple threads or
processes to ensure they do not interfere with each other while accessing shared resources.
Follow-up:
What are the different synchronization primitives available in operating systems?
Explain the concept of mutual exclusion and its importance in synchronization.
Discuss the advantages and disadvantages of busy waiting and blocking in synchronization.
Answer: Scheduling algorithms determine the order in which processes are executed by the CPU.
Common scheduling algorithms include First Come First Serve (FCFS), Shortest Job Next (SJN), Round
Robin, and Priority Scheduling.
Follow-up:
Compare and contrast preemptive and non-preemptive scheduling algorithms.
Discuss the criteria used for selecting a scheduling algorithm for a particular system.
How do real-time scheduling algorithms differ from general-purpose scheduling algorithms?
Answer: Deadlock avoidance and recovery algorithms are used to prevent deadlocks or recover from
them if they occur. Techniques include resource allocation graphs, Banker's algorithm, and rollback and
compensation mechanisms.
Follow-up:
How does Banker's algorithm prevent deadlocks in a system?
Explain the concept of transaction rollback and compensation in deadlock recovery.
Discuss the trade-offs involved in implementing deadlock avoidance and recovery algorithms.
Answer: Memory management techniques are used to manage and optimize memory usage in an
operating system. This includes allocation, deallocation, and protection of memory.
Follow-up:
Compare and contrast static and dynamic memory allocation techniques.
Explain the concept of memory fragmentation and its impact on system performance.
Discuss the advantages and disadvantages of paging and segmentation in memory management.
Let's delve deeper into the follow-up questions for each topic:
1. Virtual Memory:
3. Deadlocks:
What are the differences between binary semaphores and counting semaphores?
Binary semaphores have only two states (0 and 1) and are typically used for mutual exclusion
between processes. Counting semaphores can have values greater than 1 and are used for
controlling access to a finite number of resources.
How does deadlock can occur with locks and semaphores and how it can be prevented?
Deadlocks can occur with locks and semaphores if processes acquire resources in a different
order or if multiple locks are held simultaneously, leading to circular wait conditions. Deadlock
prevention techniques such as ensuring a fixed order for acquiring locks or using timeouts and
resource preemption can help prevent deadlocks.
Compare and contrast semaphores and monitors.
Semaphores and monitors are both synchronization primitives used to coordinate access to
shared resources. Semaphores provide low-level control over resource access using wait and
signal operations, while monitors encapsulate shared data and synchronization primitives within a
single object, providing higher-level abstraction and easier programming.
5. Synchronization Techniques:
6. Scheduling Algorithms: