OS Lab Viva Questions & Answers
OS Lab Viva Questions & Answers
Deadlocks can be prevented by ensuring that at least one of the necessary conditions for deadlocks does not hold, such as using protocols to enforce a fixed order for acquiring resources. Avoidance techniques, like the Banker’s Algorithm, ensure safe resource allocation. The trade-offs include increased complexity in resource management and potential underutilization of resources as the system may unnecessarily avoid taking safe actions .
A process is an independent entity that owns resources such as memory, open files, and CPU time. In contrast, a thread is a smaller unit of a process that can run concurrently and shares the process resources. This difference affects resource management because processes require separate memory and resources, leading to overhead, while threads within the same process can run in parallel, making resource management more efficient .
Pipes are used for communication between related processes where data flows unidirectionally, simplifying the creation of pipelines in shells. FIFOs, or named pipes, enable communication between unrelated processes by providing a persistent channel with a name in the file system. The choice affects how processes interact, as FIFOs can facilitate broader communication patterns beyond parent-child processes, enhancing flexibility .
Paging divides memory into fixed-size blocks, reducing external fragmentation while potentially increasing internal fragmentation. Segmentation, with variable-size blocks based on logical program structures, can minimize internal fragmentation but may lead to increased external fragmentation. The choice affects memory efficiency, as paging’s uniform block size simplifies management and swapping, whereas segmentation aligns better with program logic .
The Banker’s Algorithm manages resource allocation by ensuring that resources are allocated only if the system remains in a safe state, preventing deadlocks by holding back resources from processes that might lead to an unsafe state. Its limitations include the complexity of keeping track of resources and processes, and it might lead to underutilization due to conservative allocation to ensure safety .
The kernel manages core system operations such as process management, memory management, and I/O operations. A monolithic kernel integrates all services in a single layer, which can enhance performance but may reduce reliability due to more code running in kernel mode. In contrast, a microkernel runs fewer services in kernel mode, potentially increasing system reliability and security at the cost of performance due to increased inter-process communication .
A zombie process is a terminated process whose exit status hasn't been collected by the parent process, continuing to occupy the process table. Efficient handling is important to prevent resource leaks, as accumulating zombie processes can fill up the process table, preventing new processes from being created .
Preemptive scheduling allows the CPU to reallocate resources as needed, interrupting processes to run others, which can improve CPU utilization by sharing resources efficiently among processes. Non-preemptive scheduling runs a process to completion before starting another, which may lead to inefficiencies in CPU usage if a process is blocking on I/O or running long operations .
FAT is a simpler, older file system with limitations on file size and no built-in security. NTFS, used in more modern systems, supports larger files, includes security features like file permissions, and supports file compression. These differences make FAT more suitable for simpler devices or compatibility purposes, while NTFS is better for modern operating systems that require robust security and efficiency .
A context switch allows an operating system to transition the CPU from one process to another, saving and restoring the state of processes to enable multitasking. Excessive context switching can degrade performance because of the overhead involved in frequently saving and loading process states, which can reduce the time available for process execution .