0% found this document useful (0 votes)
2K views3 pages

OS Lab Viva Questions & Answers

The document provides a comprehensive list of operating system (OS) lab viva questions and their answers, covering key concepts such as processes, threads, multitasking, scheduling algorithms, deadlocks, virtual memory, and file systems. It explains essential OS functions, system calls, and process synchronization mechanisms. Additionally, it highlights differences between various OS components and algorithms, such as monolithic vs microkernel and paging vs segmentation.

Uploaded by

asishpunoff231
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)
2K views3 pages

OS Lab Viva Questions & Answers

The document provides a comprehensive list of operating system (OS) lab viva questions and their answers, covering key concepts such as processes, threads, multitasking, scheduling algorithms, deadlocks, virtual memory, and file systems. It explains essential OS functions, system calls, and process synchronization mechanisms. Additionally, it highlights differences between various OS components and algorithms, such as monolithic vs microkernel and paging vs segmentation.

Uploaded by

asishpunoff231
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

OS Lab Viva Questions with Answers

1. What is an Operating System?


- An OS manages hardware and software resources, providing services for applications.

2. What are the main functions of an OS?


- Process management, memory management, file system management, device management.

3. What is a process? How is it different from a program?


- A process is a running program with resources allocated, while a program is static.

4. What are the different states of a process?


- New, Ready, Running, Waiting, and Terminated.

5. What is a thread? How does it differ from a process?


- A thread is a lightweight process that shares resources within a process.

6. What is multitasking in an OS?


- The ability of the OS to run multiple processes simultaneously.

7. What is the difference between multitasking and multiprocessing?


- Multitasking shares CPU time among processes, while multiprocessing runs processes on multiple CPUs.

8. What is a system call? Give an example.


- A system call allows programs to interact with the OS. Example: fork().

9. What is process scheduling? Name some scheduling algorithms.


- Process scheduling decides which process runs next. Algorithms: FCFS, SJF, RR, Priority Scheduling.

10. What is the difference between preemptive and non-preemptive scheduling?


- Preemptive allows process switching anytime, non-preemptive runs a process until completion.

11. What is a deadlock? What are the conditions for a deadlock to occur?
- Deadlock is when processes block each other. Conditions: Mutual Exclusion, Hold and Wait, No Preemption, Circular Wait.

12. How can deadlocks be prevented or avoided?


- Prevention removes one of the four conditions. Avoidance uses algorithms like the Banker’s Algorithm.

13. What is virtual memory? How does it work?


- Virtual memory extends RAM using disk space, loading only needed parts into memory.

14. What is paging in OS?


- Paging divides memory into fixed-size blocks, reducing fragmentation.

15. What is the difference between paging and segmentation?


- Paging is fixed-size, segmentation is variable-size based on program structure.

16. What is a page fault? How is it handled?


- Occurs when a process accesses a page not in RAM. The OS loads it from disk.

17. What is the role of the kernel in an OS?


- The kernel is the core of the OS, managing resources and system calls.

18. What is the difference between a monolithic kernel and a microkernel?


- Monolithic includes all services, microkernel runs minimal services in kernel mode.

19. What is a semaphore? How is it used in process synchronization?


- A semaphore controls access to shared resources to prevent race conditions.
20. What is the difference between a binary semaphore and a counting semaphore?
- Binary is 0 or 1, used for mutual exclusion. Counting manages multiple resources.

21. What is a file system? What are its main functions?


- A file system organizes data storage. Functions: file creation, deletion, and access.

22. What is the difference between FAT and NTFS file systems?
- FAT is simpler but limited, NTFS supports security, compression, and larger files.

23. What is a context switch? Why is it important?


- A context switch saves a process state to switch execution to another process.

24. What is the purpose of the fork() system call in UNIX?


- Creates a new process identical to the parent.

25. What is the role of the shell in an OS?


- The shell interprets user commands and executes them via the OS.

26. What is CPU scheduling? Why is it needed?


- CPU scheduling decides process execution to optimize system performance.

27. What is the Round Robin scheduling algorithm?


- A time-sharing algorithm that assigns a fixed time slice to each process.

28. What is the First-Come-First-Serve (FCFS) scheduling algorithm?


- Executes processes in order of arrival.

29. What is the Shortest Job First (SJF) scheduling algorithm?


- Executes the shortest job first, reducing waiting time.

30. What is thrashing in OS?


- Excessive paging leading to performance degradation.

31. What is demand paging?


- Pages are loaded only when needed, reducing memory usage.

32. What is the difference between internal and external fragmentation?


- Internal: wasted space within allocated memory. External: scattered free memory.

33. What is a critical section in process synchronization?


- A code segment that accesses shared resources, requiring mutual exclusion.

34. What is the purpose of the exec() system call?


- Replaces the current process memory with a new program.

35. What is a zombie process?


- A terminated process whose exit status hasn’t been collected by the parent.

36. What is the Banker’s Algorithm?


- A deadlock avoidance method ensuring safe resource allocation.

37. What is a race condition?


- Unpredictable behavior when multiple processes access shared resources simultaneously.

38. What is inter-process communication (IPC)?


- Mechanisms for processes to communicate (e.g., pipes, shared memory).

39. What is the difference between a pipe and a FIFO?


- Pipe is for related processes, FIFO is named and can be used by unrelated processes.
40. What is the role of swap space in an OS?
- Swap space stores temporarily unused memory pages on disk.

Common questions

Powered by AI

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 .

You might also like