0% found this document useful (0 votes)
5 views9 pages

OS InterviewPrep

The document provides a comprehensive overview of operating system concepts, including system calls, process management, threading, CPU scheduling, memory management, deadlock, and synchronization. It outlines definitions, differences between terms, and examples of various algorithms and scenarios related to operating systems. Additionally, it includes a series of interview-style questions and answers to aid in preparation for OS-related interviews.

Uploaded by

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

OS InterviewPrep

The document provides a comprehensive overview of operating system concepts, including system calls, process management, threading, CPU scheduling, memory management, deadlock, and synchronization. It outlines definitions, differences between terms, and examples of various algorithms and scenarios related to operating systems. Additionally, it includes a series of interview-style questions and answers to aid in preparation for OS-related interviews.

Uploaded by

sahina.23ece
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

5. What are system calls?

Answer: System calls allow user programs to request


OS INTERVIEW STYLE QUESTIONS WITH services from the OS kernel.

ANSWERS (FULL PREPARATION) Examples: fork(), read(), write(), exec()

SECTION 1: OS BASICS
6. User Mode vs Kernel Mode?

Answer:
1. What is an Operating System?
User Mode: Limited access, runs applications.
Answer: An Operating System is system software that
manages hardware resources like CPU, memory, Kernel Mode: Full hardware access, runs OS core.
storage, and I/O devices, and provides services to
user programs. It acts as an interface between user
and hardware. SECTION 2: PROCESS MANAGEMENT

2. Why is OS called a Resource Manager? 7. What is a Process?

Answer: Because it allocates CPU time, memory, files, Answer: A process is a program in execution with its
and devices efficiently among multiple processes own memory space, registers, stack, and system
while ensuring fairness and protection. resources.

3. What happens when you power on a computer? 8. Process vs Program?

Answer: Answer:

1. BIOS/UEFI initializes hardware. Program = Passive file stored on disk

2. Bootloader loads OS kernel into RAM. Process = Active execution of program

3. Kernel initializes memory, CPU, drivers.

4. Init process starts system services. 9. What are process states?

5. Login screen appears. Answer: New, Ready, Running, Waiting/Blocked,


Terminated.

4. Difference between Kernel and OS?


10. What is PCB?
Answer:
Answer: Process Control Block stores PID, process
OS = Full system software (includes utilities + kernel)
state, program counter, CPU registers, and memory
Kernel = Core part of OS that directly interacts with information.
hardware
11. What is context switching? User Threads are managed by user-level libraries.

Answer: Saving the state of current process and Kernel Threads are managed by the operating system
loading the state of another process so CPU can and allow true parallelism.
switch execution. It is expensive because it involves
saving registers and memory mapping.
SECTION 4: CPU SCHEDULING

12. What is a Zombie Process?

Answer: A process that has finished execution but 18. What is Scheduling?
still has an entry in process table because parent has Answer: Selecting which process gets CPU next.
not read its exit status.

19. What is Preemptive Scheduling?


13. What is an Orphan Process?
Answer: CPU can be taken from a running process
Answer: If parent process terminates before child, (e.g., Round Robin).
the child becomes orphan and is adopted by init
process.

20. Why is SJF optimal?

SECTION 3: THREADS Answer: It gives minimum average waiting time


because shortest jobs execute first.

14. What is a Thread?


21. What is starvation?
Answer: A thread is the smallest unit of execution
within a process. Answer: When a low-priority process never gets CPU.
Common in Priority Scheduling.

15. Process vs Thread?


22. What happens if time quantum is very large in
Answer: Round Robin?
Process: Separate memory, heavyweight. Answer: It behaves like FCFS.
Thread: Shared memory, lightweight.

SECTION 5: DEADLOCK
16. Why are threads faster?

Answer: Because threads share memory and context 23. What is Deadlock?
switching is cheaper compared to processes.
Answer: A situation where processes wait
indefinitely for each other’s resources.
17. User Threads vs Kernel Threads?

Answer:
24. Four conditions of deadlock?

Answer: 31. Internal vs External Fragmentation?

1. Mutual Exclusion Answer:

2. Hold and Wait Internal: Wasted space inside allocated block.

3. No Preemption External: Free memory scattered.

4. Circular Wait

SECTION 7: SYNCHRONIZATION

25. How to prevent deadlock?

Answer: Break at least one of the four necessary 32. What is Critical Section?
conditions.
Answer: Code segment where shared data is
accessed.

26. What is Banker’s Algorithm?

Answer: A deadlock avoidance algorithm that checks 33. What is Semaphore?


if system remains in safe state after allocation.
Answer: A synchronization variable used to control
access to shared resources.

SECTION 6: MEMORY MANAGEMENT

34. Mutex vs Semaphore?

27. What is Paging? Answer:

Answer: Dividing memory into fixed-size pages and Mutex = Locking mechanism (only one thread)
frames.
Semaphore = Signaling + resource control (can allow
multiple)

28. What is Page Fault?

Answer: Occurs when required page is not in RAM. 35. What is Race Condition?

Answer: When multiple threads access shared data


and output depends on execution order.
29. What is Virtual Memory?

Answer: Technique that allows execution of large


programs by using disk as extension of RAM. 36. What is Producer Consumer Problem?

Answer: A classic synchronization problem where


producer produces data and consumer consumes it
30. What is Thrashing? using shared buffer safely.
Answer: Excessive page faults causing CPU to spend
more time swapping than executing.
SECTION 8: DISK & I/O

43. How does OS ensure security?

37. What is Disk Scheduling? Answer: Using user/kernel mode, memory


protection, authentication, and access control.
Answer: Technique to decide order of disk I/O
requests (FCFS, SSTF, SCAN, C-SCAN).

44. What is Copy-on-Write?

38. What is Interrupt? Answer: Memory pages are shared until modification
occurs; then a copy is created.
Answer: A signal from hardware that interrupts CPU
to handle an event immediately.

45. What is TLB?

39. Polling vs Interrupt? Answer: Translation Lookaside Buffer is a cache that


stores recent page table entries to speed up address
Answer: translation.
Polling = CPU checks device continuously (wastes
CPU).

Interrupt = Device notifies CPU only when needed


(efficient).

ADVANCED QUESTIONS

40. What happens during a context switch at


hardware level?

Answer: CPU registers, program counter, and stack


pointer are saved into PCB and new process state is
loaded.

41. Can deadlock occur with single process?

Answer: No, because circular wait requires at least


two processes.

42. Why is multithreading useful in web servers?

Answer: It allows handling multiple client requests


concurrently while sharing memory efficiently.
🔰 SECTION 1: OS BASICS

Q1. The primary purpose of an Operating System Q7. PCB (Process Control Block) contains:
is to: A) Process state and registers ☐
A) Compile programs ☐ B) Only program code ☐
B) Manage hardware and software resources ☐ C) Disk scheduling data ☐
C) Execute only user programs ☐ D) Cache memory entries ☐
D) Design applications ☐

Q8. Context switching refers to:


Q2. Which component directly interacts with A) Switching between user and kernel mode ☐
hardware? B) Saving and loading process state ☐
A) Shell ☐ C) Changing memory pages ☐
B) Kernel ☐ D) Interrupt handling only ☐
C) Compiler ☐
D) Loader ☐
Q9. Which state follows the Ready state in a
normal flow?
Q3. A system call is used to: A) Running ☐
A) Access hardware directly ☐ B) Waiting ☐
B) Request services from the OS ☐ C) New ☐
C) Execute machine code ☐ D) Terminated ☐
D) Manage cache ☐

Q10. A zombie process is:


Q4. Which mode has full access to hardware? A) A running process with high priority ☐
A) User mode ☐ B) A terminated process still in process table ☐
B) Kernel mode ☐ C) A blocked process waiting for I/O ☐
C) Safe mode ☐ D) A suspended thread ☐
D) Batch mode ☐

🧵 SECTION 3: THREADS
Q5. Which OS structure is faster but less secure?
A) Microkernel ☐ Q11. Threads within the same process share:
B) Monolithic kernel ☐ A) Address space ☐
C) Layered OS ☐ B) Separate memory blocks ☐
D) Virtual machine ☐ C) Different kernels ☐
D) Different page tables ☐

⚙️SECTION 2: PROCESS MANAGEMENT


Q12. A thread is also called:
Q6. A process is best defined as: A) Heavyweight process ☐
A) A program in execution ☐ B) Lightweight process ☐
B) A file stored in memory ☐ C) Batch job ☐
C) A thread unit ☐ D) Kernel daemon ☐
D) A scheduler instance ☐
Q13. Why are threads faster than processes? Q19. Preemptive scheduling means:
A) They use separate memory ☐ A) CPU cannot be interrupted ☐
B) They avoid context switching ☐ B) Running process can be interrupted ☐
C) They share memory and resources ☐ C) Only one process executes fully ☐
D) They run only in kernel mode ☐ D) No context switching occurs ☐

Q14. User-level threads are managed by: 💀 SECTION 5: DEADLOCK


A) Operating system kernel ☐
B) User-level thread library ☐ Q20. Deadlock is a situation where:
C) Hardware scheduler ☐ A) CPU is idle ☐
D) BIOS ☐ B) Processes wait indefinitely for resources ☐
C) Memory is overused ☐
D) Interrupts fail ☐

🧮 SECTION 4: CPU SCHEDULING

Q15. Which scheduling algorithm minimizes Q21. Which is NOT a necessary condition for
average waiting time? deadlock?
A) FCFS ☐ A) Mutual exclusion ☐
B) SJF ☐ B) Hold and wait ☐
C) Round Robin ☐ C) Circular wait ☐
D) Priority ☐ D) Infinite memory ☐

Q16. Round Robin scheduling is best suited for: Q22. Banker’s Algorithm is used for:
A) Batch systems ☐ A) Deadlock avoidance ☐
B) Time-sharing systems ☐ B) CPU scheduling ☐
C) Real-time hard systems ☐ C) Paging ☐
D) Embedded ROM systems ☐ D) Disk management ☐

Q17. Starvation mainly occurs in:


A) FCFS scheduling ☐
B) Priority scheduling ☐
C) Round Robin ☐ 🧠 SECTION 6: MEMORY MANAGEMENT
D) FIFO scheduling ☐
Q23. Paging is used to:
A) Eliminate external fragmentation ☐
Q18. If the time quantum in Round Robin is very B) Increase CPU speed ☐
large, it behaves like: C) Prevent deadlock ☐
A) SJF ☐ D) Manage cache memory ☐
B) FCFS ☐
C) Priority ☐
D) Multilevel queue ☐ Q24. A page fault occurs when:
A) Page is found in RAM ☐
B) Page is not present in main memory ☐
C) CPU cache misses ☐ A) CPU utilization is high ☐
D) TLB is full ☐ B) Excessive paging occurs ☐
C) Disk scheduling fails ☐
D) Context switching stops ☐
Q25. Virtual memory allows:
A) Programs larger than RAM to execute ☐
B) Faster disk access ☐ 31. A counting semaphore value can be:
C) Elimination of paging ☐
D) Only kernel execution ☐ A) Only 0 or 1 ☐
B) Only negative ☐
C) Any integer value ☐
D) Only positive even numbers ☐
26. What does the TLB (Translation Lookaside
Buffer) store?

A) Cache data ☐ 32. Binary semaphore is also known as:


B) Page table entries ☐
C) File descriptors ☐ A) Mutex ☐
D) Process states ☐ B) Monitor ☐
C) Spinlock ☐
D) Barrier ☐

27. Belady’s Anomaly is associated with which


algorithm?
33. The critical section problem requires which
A) LRU ☐ conditions?
B) FIFO ☐
C) Optimal ☐ A) Mutual exclusion ☐
D) MRU ☐ B) Progress ☐
C) Bounded waiting ☐
D) All of the above ☐

28. External fragmentation mainly occurs in:

A) Paging ☐ 34. Which scheduling algorithm is preemptive?


B) Segmentation ☐
C) Virtual memory ☐ A) FCFS ☐
D) Cache memory ☐ B) Non-preemptive SJF ☐
C) Round Robin ☐
D) FIFO ☐

29. A page fault occurs when:

A) Page is in main memory ☐ 35. Time quantum is a key parameter in:


B) Page is not in main memory ☐
C) CPU is idle ☐ A) Priority Scheduling ☐
D) Cache is full ☐ B) Round Robin Scheduling ☐
C) FCFS Scheduling ☐
D) SJF Scheduling ☐

30. Thrashing happens when:

36. Context switching involves:


A) Saving and restoring process state ☐ 42. Internal fragmentation is commonly seen in:
B) Increasing RAM size ☐
C) Reducing disk access ☐ A) Segmentation ☐
D) Clearing cache memory ☐ B) Paging ☐
C) Linked allocation ☐
D) Indexed allocation ☐

37. Banker’s Algorithm is used for:

A) Deadlock prevention ☐ 43. Threads of the same process share:


B) Deadlock avoidance ☐
C) Deadlock detection ☐ A) Registers ☐
D) Deadlock recovery ☐ B) Stack ☐
C) Code and data segment ☐
D) Program counter ☐

38. Deadlock detection in systems with single


instance resources uses:
44. System calls provide an interface between:
A) Resource Allocation Graph ☐
B) Page Table ☐ A) Hardware and CPU ☐
C) TLB ☐ B) User programs and Kernel ☐
D) Stack ☐ C) RAM and Disk ☐
D) Compiler and OS ☐

39. Which disk scheduling algorithm provides


minimum seek time (on average)? 45. Multiprogramming improves:

A) FCFS ☐ A) CPU utilization ☐


B) SSTF ☐ B) Disk fragmentation ☐
C) SCAN ☐ C) Response time only ☐
D) C-SCAN ☐ D) Cache hit ratio ☐

40. SCAN disk scheduling is also called: 46. A race condition occurs when:

A) Circular algorithm ☐ A) Two processes run sequentially ☐


B) Elevator algorithm ☐ B) Multiple processes access shared data
C) Priority algorithm ☐ concurrently ☐
D) Random algorithm ☐ C) CPU scheduling fails ☐
D) Deadlock is detected ☐

41. In segmentation, a logical address consists of:


47. Which of the following is a non-preemptive
A) Page number and offset ☐ scheduling algorithm?
B) Segment number and offset ☐
C) Frame number and offset ☐ A) Round Robin ☐
D) Block number and index ☐ B) SRTF ☐
C) FCFS ☐
D) Preemptive Priority ☐
48. In linked file allocation, each file contains:

A) Contiguous blocks ☐
B) Pointers to next block ☐
C) Index table only ☐
D) Fixed size frames ☐

49. Kernel mode allows:

A) Only user-level instructions ☐


B) Privileged instructions execution ☐
C) Running text editors only ☐
D) File viewing only ☐

50. The primary goal of an Operating System is to:

A) Execute only user programs ☐


B) Manage hardware and system resources efficiently

C) Increase program size ☐
D) Replace the compiler ☐

You might also like