Operating System Viva Questions with Simple Answers:
1. Define operating system?
→ OS manages computer hardware and software.
2. What are the different types of operating systems?
→ Batch, Time-sharing, Distributed, Real-time, Embedded.
3. Define a process?
→ Process is a running program.
4. What are the contents of PCB?
→ Process ID, state, registers, program counter, memory info.
5. What is CPU Scheduling?
→ Selecting a process for execution.
6. Define arrival time, burst time, waiting time, turnaround time?
→ Arrival time: time entered queue.
→ Burst time: execution time.
→ Waiting time: time waiting.
→ Turnaround time: completion time - arrival time.
7. What are the different CPU scheduling criteria?
→ CPU utilization, Throughput, Waiting time, Response time.
8. What is the advantage of round robin CPU scheduling algorithm?
→ Equal time for all processes.
9. Which CPU scheduling algorithm is for real-time operating system?
→ Priority Scheduling.
10. In general, which CPU scheduling algorithm works with highest waiting time?
→ FCFS (First Come First Serve).
11. Is it possible to use optimal CPU scheduling algorithm in practice?
→ No, future burst times are unknown.
12. What is the real difficulty with the SJF CPU scheduling algorithm?
→ Needs future burst time.
13. Differentiate between general CPU scheduling algorithms and multi-level queue scheduling?
→ Multi-level queue has separate queues for processes.
14. What are CPU-bound and I/O-bound processes?
→ CPU-bound uses CPU more, I/O-bound uses input/output more.
15. What is the need for process synchronization?
→ To avoid conflicts in shared resources.
16. What is a critical section?
→ Part where shared resources are accessed.
17. Define a semaphore?
→ Variable used for process synchronization.
18. Define producer-consumer problem?
→ Managing shared buffer between producer & consumer.
19. Consequences of bounded & unbounded buffers?
→ Bounded limits items, unbounded has no limit.
20. Can producer and consumer access shared memory concurrently?
→ No, Semaphore allows safe access.
21. Differentiate between monitor, semaphore, and binary semaphore?
→ Monitor - high-level, Semaphore - integer, Binary Semaphore - 0 or 1.
22. Define dining-philosophers problem?
→ Philosophers share forks to eat.
23. Scenarios leading to deadlock in dining-philosophers?
→ All hold one fork and wait for other.
24. Define file?
→ Collection of related data.
25. What are the different kinds of files?
→ Text, Binary, Executable, Directory.
26. Purpose of file allocation strategies?
→ Manage disk space efficiently.
27. Scenarios for sequential, indexed, linked allocation?
→ Sequential - simple files, Indexed - direct access, Linked - flexible files.
28. Disadvantages of sequential file allocation?
→ Slow random access.
29. What is an index block?
→ Stores addresses of file blocks.
30. File allocation strategy used in UNIX?
→ Indexed allocation.
31. What is dynamic memory allocation?
→ Allocating memory during runtime.
32. What is external fragmentation?
→ Scattered unused memory spaces.
33. Which allocation strategies suffer from external fragmentation?
→ Contiguous allocation.
34. Solutions for external fragmentation?
→ Compaction, Paging, Segmentation.
35. What is 50-percent rule?
→ 1/3rd memory wasted due to fragmentation.
36. What is compaction?
→ Moving processes to remove free space.
37. Which of first-fit, best-fit, worst-fit is efficient? Why?
→ Best-fit - less wastage, but slower.
38. Advantages of noncontiguous allocation?
→ Avoids fragmentation.
39. Mapping logical to physical address in paging?
→ Physical address = base + offset.
40. Define base address and offset?
→ Base - starting address, Offset - distance from base.
41. Differentiate paging and segmentation?
→ Paging - fixed size blocks, Segmentation - variable size blocks.
42. Purpose of page table?
→ Maps logical to physical address.
43. Paging suffers from internal or external fragmentation? Why?
→ Internal - fixed size pages.
44. Effect of paging on context-switching time?
→ Increases due to page table switching.
45. Define directory?
→ Collection of files.
46. Describe general directory structure?
→ Single level, Two level, Tree, Acyclic Graph.
47. Types of directory structures?
→ Single, Two-level, Tree, DAG.
48. Efficient directory structure? Why?
→ Tree - easy to manage large systems.
49. Directory structure without isolation?
→ Single level.
50. Advantage of hierarchical directory structure?
→ Organized file management.
51. Define resource. Give examples.
→ Anything used by process - CPU, memory, printer.
52. What is deadlock?
→ Processes wait forever for resources.
53. Conditions for deadlock?
→ Mutual exclusion, Hold & Wait, No preemption, Circular wait.
54. Resource allocation graph for deadlock?
→ Shows cycle if deadlock occurs.
55. Use of Banker’s algorithm?
→ Prevents deadlock by safe state checking.
56. Difference between deadlock avoidance and prevention?
→ Avoidance - checks before allocation, Prevention - eliminates conditions.
57. What is disk scheduling?
→ Managing disk I/O requests.
58. Different disk scheduling algorithms?
→ FCFS, SSTF, SCAN, C-SCAN, LOOK.
59. Define disk seek time, access time, rotational latency?
→ Seek time - move head, Access time - total time, Latency - rotation delay.
60. Advantage of C-SCAN over SCAN?
→ Uniform wait time.
61. Algorithm with highest rotational latency? Why?
→ FCFS - far requests possible.
62. Define virtual memory?
→ Uses hard disk as extra RAM.
63. Purpose of page replacement?
→ Manage limited RAM.
64. General process of page replacement?
→ Remove page, load new one.
65. Page replacement techniques?
→ FIFO, LRU, Optimal, LFU.
66. What is page fault?
→ Page not in memory.
67. Algorithm suffering Belady’s anomaly?
→ FIFO.
68. Define thrashing? When it happens?
→ Too many page faults, low performance.
69. Benefits of optimal page replacement?
→ Least page faults.
70. Why optimal page replacement is not practical?
→ Needs future knowledge.
71. Command to count number of words in file?
→ wc -w filename
72. Command to give execute permission to bash file?
→ chmod +x filename.sh
73. Command to create file and display content?
→ cat > filename and cat filename
74. Command for pattern matching letter O in HELLO WORLD?
→ grep 'O' filename
75. System call to create process?
→ fork()
76. System call wait(&status) means?
→ Wait for child to finish.
77. System calls for file manipulation?
→ open, read, write, close, unlink.
78. Command to create and remove directory?
→ mkdir dirname, rmdir dirname
79. Command to know who is logged in?
→ who
80. What is process? States of process?
→ Program in execution. States: New, Ready, Running, Waiting, Terminated.
81. Command to print message in shell?
→ echo "message"
82. Syntax of shell statements:
→ a) if [ condition ]; then ... else ... fi
→ b) case value in pattern) commands;; esac
→ c) while [ condition ]; do commands; done
83. Shell program to add two numbers?
→ echo $((a+b))
84. Access permissions for file?
→ Read (r), Write (w), Execute (x)
85. Syntax of open system call?
→ int open(const char *pathname, int flags)