Top OS Interview Questions: Part 2 (2021)

Top OS Interview Questions: Part 2 (2021)
Top OS Interview Questions: Part 2 (2021)

Introduction

The blog covers top 33 interview level Operating System Interview Questions. Let’s continue learning about the top Operating System Interview Questions and their answers asked by leading tech companies .

Intermediate Operating System Interview Questions

Q1. What is the difference between a microkernel and a microkernel in an Operating System ?

Answer: 

Microkernel: It is the kernel that runs at minimal performance, affecting services of the OS. In the microkernel operating system, the processor performs all other operations.

Macro Kernel: It is a combination of monolithic and microkernels.

Q2. What is virtual memory in an Operating System?

Answer:  It’s a memory management technique that helps processes to execute outside of memory. We use this technique when an executing program cannot fit in the physical memory.

Q3. What is fragmentation in Operating System?

Answer: It is a phenomenon of memory wastage. Since the space is used inefficiently, It reduces the capacity and performance.

Q4. What is the use of paging in an operating system?

Answer: Paging solves the external fragmentation problem. It ensures that the data needed is available as quickly as possible.

Q5. Explain the concept of demand paging? 

Answer: It explains that if an area of memory in the Operating System is not used currently, it is swapped to the disk to make room for an application’s need.

Q6. How many types of fragmentation occur in the Operating System?

Answer: There are two types of fragmentation that occur in Operating System:

  • Internal fragmentation: It occurs when systems have fixed-size allocation units.
  • External fragmentation: It appears when we deal with techniques that have variable-size allocation units.

Q7. Explain spooling.

Answer: It is a process in which data to be used is temporarily gathered and executed by a device, program, or system. 

It is related to printing, i.e., when different applications simultaneously send output to the printer, spooling queues all these jobs into a disk file.

Q8. What is the difference between external commands and internal commands in an Operating System?

Answer: 

External commands: These are separate file programs that are stored in a different folder or directory.

Internal commands: These are the built-in part of the operating system.

Q9. What is thrashing in the Operating System?

Answer: Thrashing occurs in virtual memory schemes when the processor spends most of its time swapping pages rather than executing instructions.

Q10.When does thrashing occur in OS?

Answer: Thrashing specifies an instance of high paging activity. This usually happens when it is spending more time in paging instead of executing commands.

Q11.  What is PCB?

Answer: Each process in the operating system is represented by a process control block (PCB). PCB is also called a task control block

It contains many bits of information associated with a specific process. So, It serves as the repository for any information that may vary from process to process.

Q12. Explain the various pieces of information stored in a OS’s PCB wrt to a process.

Answer: 

  1. Process state: It may be new, ready, waiting, running, halted, etc. 
  2. Program counter: It stores the address of the next instruction to be executed for the particular process. 
  3. CPU registers: Depending on the computer architecture, they vary in type and number. They include stack pointers, accumulators, index registers, and general-purpose registers, any condition-code information.
  4. CPU-scheduling information. It includes a process priority, pointers to scheduling queues, and any other scheduling parameters. 
  5. Memory-management information. This information may include items such as the value of the base and limit registers and the segment tables or the page tables, depending on the memory system used by OS. 
  6. Accounting information. It includes real-time use, the amount of CPU, time limits, job or process numbers, etc. 
  7. I/O status information. It includes the list of open files, the list of I/O devices allocated to the process, and so on. 
process_control_block

Q13. What is caching in the Operating System?

Answer: The cache in OS is a fast and small memory that stores data from frequently used main memory locations. Cache memory reduces the average time to access the data from the Main memory. 

Q14. What are overlays in the Operating System?

Answer: Overlays make a process to be larger than the amount of memory allocated to it. It ensures that only essential data and instructions at any given time are kept in memory.

Q15. How does dynamic loading help in better memory space utilization in the Operating System?

Answer: Dynamic loading ensures a routine is not loaded until it is called. This method is beneficial when large amounts of code are needed to handle infrequently occurring cases such as error routines.

Q16. How does swapping ensure better memory management in the Operating System?

Answer: Swapping is a simple memory/process management technique used by OS to increase the utilization of the processor. It moves some blocked processes from the main memory to the secondary memory, forming a queue of the temporarily suspended processes, and the execution continues with the newly arrived process. During regular intervals set by the operating system, processes can be copied from the main memory to a backing store and then copied back later. Swapping allows more processes to be run that can fit into memory at one time.

Q17. What is the best page size when designing an OS?

Answer: The best paging size varies from system to system. There are different factors to consider to come up with a suitable page size, such as paging time, page table, and its effect on the overall efficiency of the operating system.

Q18. Explain the process-scheduling concept and the use of scheduling queues.

Answer:

  • When the processes enter the system, they are put into a job queue.∙ 
  • The processes that reside in the main memory and are ready and waiting to execute are kept on the ready queue list. 
  • When a process is allocated to the CPU, it executes for a while. Eventually, it quits, is interrupted, or waits for the occurrence of a particular event, such as the completion of an I/O request. 

Since there are many processes in the system, the disk(or any shared device to which a request is made) may be busy with the I/O request of some other process. So, the process may have to wait for the disk. 

The list of processes waiting for a particular I/O device is called a device queue. Each device has its own device queue

  • First, a new process is put in the ready queue. It waits there until it is called for execution or dispatched. 

      Once the process is allocated to the CPU and starts executing:

o The process could issue an I/O request and then be placed in an I/O queue. 

o The process could create a new child process and wait for the child’s termination. 

o The process could be removed forcibly from the CPU due to an interrupt and be put back in the ready queue. 

           

queing_diagram

Q19. What are the two common types of Schedulers in the Operating System?

Answer: 

The operating system selects processes from scheduling queues via appropriate scheduler

There are mainly two types of schedulers: 

Long-Term SchedulerShort-Term Scheduler
It is also known as Job SchedulerIt is also known as CPU Scheduler
It selects processes from scheduling queues and loads them into memory for execution. It selects one of the processes that are ready to execute and allocates it to the CPU. 
It executes much less frequently; minutes may separate the creation of one new process and the next. It also controls the degree of multiprogramming. Thus, the long-term scheduler may need to be invoked only when a process leaves the system.It frequently selects a new process for the CPU and executes at least once every 100  milliseconds.  

Q20. What is the difference between physical address space and logical address space in the Operating System?

Answer:

Logical Address SpacePhysical Address Space
It specifies the address that is generated by CPUIt specifies the address that is seen by the memory unit.
Users can view the logical address of a program.Users can never view the physical address of the program.
The user can use the logical address to access the physical address.The user can indirectly access physical addresses but not directly.

Q21. What is the difference between different fragmentation types in the Operating System?

Answer: 

Internal FragmentationExternal Fragmentation
It is the difference between the memory allocated and the required memory.It is the small unused space between the non-contiguous memory fragments to accommodate a process request.
It refers to the unused space in the partition in the allocated region.It refers to the unused memory blocks that are too small to handle a request.
It can be eliminated by dynamically allocating memory to processes.It can be eliminated by compaction, segmentation and paging.

Q22. Difference between process and threads in the Operating System?

ProcessThreads
Fork() system call is used to create a process.There is no system call involved to call the thread.
Different processes are treated differently.All user level threads are treated as single tasks for the OS.
Context Switching is slowerContext Switching is faster.

Q23. What is the deadlock in OS?

Answer: Deadlock in the operating system is a unique condition where two processes wait for each other infinitely to complete so that they can resume their process.

Q24. What are the four sufficient and necessary conditions for the deadlock?

Answer: 

The four necessary and sufficient conditions are:

1) Hold and Wait Condition: It specifies that there must be a process holding a resource already allocated to it while waiting for additional resources currently being held by other processes.

2) Mutual Exclusion Condition: It specifies that the resources involved are non-sharable.

3) Circular Wait Condition: It specifies that the processes in the system form a circular list or a chain where each process in the chain is waiting for a resource held by the following process in the chain. 

4) No-Preemptive Condition: Resources cannot be taken away while processes are using them.

Q25. What is Banker’s algorithm?

Answer: Banker’s algorithm in the operating system is used to avoid deadlock. It is named so due to the banking system where the bank never allocates available cash in such a manner that it can no longer satisfy the requirements of all of its customers.

Q26. What is semaphore in an OS?

Answer: Semaphore in the operating system is a protected variable or abstract data type used to lock the resource being used. The value of the semaphore indicates the status of a shared resource.

There are two types of semaphore:

  • Binary semaphores
  • Counting semaphores

Q27. What is a binary Semaphore in OS?

Answer: Binary semaphore takes only 0 and 1 as values, implements mutual exclusion, and synchronizes concurrent processes.

Q28.. What is starvation in the Operating System?

Answer: Starvation is a Resource management problem. A waiting process does not get the resources it needs for a long time because it is allocated to other processes.

Q29. What is a thread?

Answer: A thread is a basic unit of CPU utilization. It consists of a thread ID, program counter, register set, and a stack.

Q30. What is  FCFS in the Operating System?

Answer: FCFS stands for First Come, First Served. It is a type of scheduling algorithm where if a process requests the CPU first, it is allocated to the CPU first. A FIFO queue manages its implementation.

Q31. What is Belady’s Anomaly?

Answer: Belady’s Anomaly in OS is also called FIFO anomaly. Usually, the process execution increases the number of frames allocated to a process virtual memory because fewer page faults occur. Sometimes, the reverse happens, i.e., the execution time increases even when more frames are assigned to the process. This is Belady’s Anomaly. This is true for specific page reference patterns.

Q32. What is SMP in the Operating System?

Answer: SMP stands for Symmetric MultiProcessing. It is the most common type of multiple processor system. In SMP, each processor runs an identical copy of the operating system, and these copies communicate with one another when required.

Q33. What is RAID? What are the different RAID levels in the Operating System?

Answer: RAID stands for Redundant Array of Independent Disks. It is used to store the same data redundantly to improve the overall performance.

Following are the different RAID levels:

RAID 0 – Striped Disk Array without fault tolerance

RAID 1 – Mirroring and duplexing

RAID 2 – Memory-style error-correcting codes

RAID 3 – Bit-interleaved Parity

RAID 4 – Block-interleaved Parity

RAID 5 – Block-interleaved distributed Parity

RAID 6 – P+Q Redundancy

Key Takeaways

In this blog, we enlisted the top 33 Operating System Interview questions that are highly probable to be asked in interviews. In this series of questions, we have also covered more basic level questions in  Top Operating System Interview Questions part 1. Do check them out in case you missed them. If you like this blog, do share it with your friends!

By: Raksha Jain