Intermediate OS Interview Questions

 61. Write a difference between a user-level thread and a kernel-level thread?

User-level thread

Kernel level thread

User threads are implemented by users. kernel threads are implemented by OS.
OS doesn’t recognize user-level threads. Kernel threads are recognized by OS.
Implementation of User threads is easy. Implementation of the perform kernel thread is complicated.
Context switch time is less. Context switch time is more.
Context switch requires no hardware support. Hardware support is needed.
If one user-level thread performs a blocking operation then entire process will be blocked. If one kernel thread perform a the blocking operation then another thread can continue execution.
User-level threads are designed as dependent threads. Kernel level threads are designed as independent threads.

62.  Write down the advantages of multithreading?

Some of the most important benefits of MT are:

  • Improved throughput. Many concurrent compute operations and I/O requests within a single process.
  • Simultaneous and fully symmetric use of multiple processors for computation and I/O.
  • Superior application responsiveness. If a request can be launched on its own thread, applications do not freeze or show the “hourglass”. An entire application will not block or otherwise wait, pending the completion of another request.
  • Improved server responsiveness. Large or complex requests or slow clients don’t block other requests for service. The overall throughput of the server is much greater.
  • Minimized system resource usage. Threads impose minimal impact on system resources. Threads require less overhead to create, maintain, and manage than a traditional process.
  • Program structure simplification. Threads can be used to simplify the structure of complex applications, such as server-class and multimedia applications. Simple routines can be written for each activity, making complex programs easier to design and code, and more adaptive to a wide variation in user demands.
  • Better communication. Thread synchronization functions can be used to provide enhanced process-to-process communication. In addition, sharing large amounts of data through separate threads of execution within the same address space provides extremely high-bandwidth, low-latency communication between separate tasks within an application

63. Difference between Multithreading and Multitasking?

S.No

Multi-threading

Multi-tasking

1. Multiple threads are executing at the same time at the same or different part of the program. Several programs are executed concurrently.
2. CPU switches between multiple threads. CPU switches between multiple tasks and processes.
3.  It is the process of a lightweight part.  It is a heavyweight process.
4. It is a feature of the process.  It is a feature of the OS.
5. Multi-threading is sharing of computing resources among threads of a single process. Multitasking is sharing of computing resources(CPU, memory, devices, etc.) among processes.

64. What are the drawbacks of semaphores?

  • Priority Inversion is a big limitation of semaphores.
  • Their use is not enforced but is by convention only.
  • The programmer has to keep track of all calls to wait and signal the semaphore.
  • With improper use, a process may block indefinitely. Such a situation is called Deadlock.

65. What is Peterson’s approach?

 It is a concurrent programming algorithm. It is used to synchronize two processes that maintain the mutual exclusion for the shared resource. It uses two variables, a bool array flag of size 2 and an int variable turn to accomplish it.

66. Define the term Bounded waiting?

A system is said to follow bounded waiting conditions if a process wants to enter into a critical section will enter in some finite time.

67. What are the solutions to the critical section problem?

There are three solutions to the critical section problem:

  • Software solutions
  • Hardware solutions
  • Semaphores

68. What is a Banker’s algorithm?

The banker’s algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating the allocation for the predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible activities, before deciding whether allocation should be allowed to continue.

69. What is concurrency?

A state in which a process exists simultaneously with another process than those it is said to be concurrent.

70. Write a drawback of concurrency?

  • It is required to protect multiple applications from one another.
  • It is required to coordinate multiple applications through additional mechanisms.
  • Additional performance overheads and complexities in operating systems are required for switching among applications.
  • Sometimes running too many applications concurrently leads to severely degraded performance.

71. What are the necessary conditions which can lead to a deadlock in a system?

Mutual Exclusion: There is a resource that cannot be shared. 
Hold and Wait: A process is holding at least one resource and waiting for another resource, which is with some other process. 
No Preemption: The operating system is not allowed to take a resource back from a process until the process gives it back. 
Circular Wait:  A set of processes waiting for each other in circular form. 

72. What are the issues related to concurrency?

  • Non-atomic: Operations that are non-atomic but interruptible by multiple processes can cause problems.
  • Race conditions: A race condition occurs of the outcome depends on which of several processes gets to a point first.
  • Blocking: Processes can block waiting for resources. A process could be blocked for a long period of time waiting for input from a terminal. If the process is required to periodically update some data, this would be very undesirable.
  • Starvation: It occurs when a process does not obtain service to progress.
  • Deadlock: It occurs when two processes are blocked and hence neither can proceed to execute

73. Why do we use precedence graphs?

A precedence graph is a directed acyclic graph that is used to show the execution level of several processes in the operating system. It has the following properties also:

  • Nodes of graphs correspond to individual statements of program code.
  • An edge between two nodes represents the execution order.
  • A directed edge from node A to node B shows that statement A executes first and then Statement B executes

74. Explain the resource allocation graph?

The resource allocation graph is explained to us what is the state of the system in terms of processes and resources. One of the advantages of having a diagram is, sometimes it is possible to see a deadlock directly by using RAG.

75. What is a deadlock?  

Deadlock is a situation when two or more processes wait for each other to finish and none of them ever finish.  Consider an example when two trains are coming toward each other on the same track and there is only one track, none of the trains can move once they are in front of each other.  A similar situation occurs in operating systems when there are two or more processes that hold some resources and wait for resources held by other(s). 

76. What is the goal and functionality of memory management?

The goal and functionality of memory management are as follows;

  • Relocation
  • Protection
  • Sharing
  • Logical organization
  • Physical organization

77. Write a difference between physical address and logical address?

S.NO. Parameters Logical address Physical Address
1. Basic It is the virtual address generated by CPU. The physical address is a location in a memory unit.
2. Address Set of all logical addresses generated by the CPU in reference to a program is referred to as Logical Address Space. Set of all physical addresses mapped to the corresponding logical addresses is referred to as a Physical Address. 
3. Visibility The user can view the logical address of a program. The user can never view the physical address of the program
4. Access The user uses the logical address to access the physical address. The user can not directly access the physical address
5. Generation The Logical Address is generated by the CPU Physical Address is Computed by MMU

78. Explain address binding?

The Association of program instruction and data to the actual physical memory locations is called Address Binding.

79. Write different types of address binding?

Address Binding is divided into three types as follows.

80. Write an advantage of dynamic allocation algorithms?

  • When we do not know how much amount of memory would be needed for the program beforehand.
  • When we want data structures without any upper limit of memory space.
  • When you want to use your memory space more efficiently.
  • Dynamically created lists insertions and deletions can be done very easily just by the manipulation of addresses whereas in the case of statically allocated memory insertions and deletions lead to more movements and wastage of memory.
  • When you want to use the concept of structures and linked lists in programming, dynamic memory allocation is a must

81. Write a difference between internal fragmentation and external fragmentation?

S.NO Internal fragmentation External fragmentation
1. In internal fragmentation fixed-sized memory, blocks square measure appointed to process. In external fragmentation, variable-sized memory blocks square measure appointed to the method.
2. Internal fragmentation happens when the method or process is larger than the memory. External fragmentation happens when the method or process is removed.
3. The solution to internal fragmentation is the best-fit block. Solution for external fragmentation is compaction, paging and segmentation.
4. Internal fragmentation occurs when memory is divided into fixed-sized partitions. External fragmentation occurs when memory is divided into variable-size partitions based on the size of processes.
5. The difference between memory allocated and required space or memory is called Internal fragmentation. The unused spaces formed between non-contiguous memory fragments are too small to serve a new process, which is called External fragmentation.

82. Define the Compaction?

The process of collecting fragments of available memory space into contiguous blocks by moving programs and data in a computer’s memory or disk.

83. Write about the advantages and disadvantages of a hashed-page table?

Advantages

  • The main advantage is synchronization.
  • In many situations, hash tables turn out to be more efficient than search trees or any other table lookup structure. For this reason, they are widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.

Disadvantages

  • Hash collisions are practically unavoidable. when hashing a random subset of a large set of possible keys.
  • Hash tables become quite inefficient when there are many collisions.
  • Hash table does not allow null values, like a hash map.
  • Define Compaction.

84. Write a difference between paging and segmentation?

S.NO

Paging

Segmentation

1. In paging, program is divided into fixed or mounted-size pages. In segmentation, the program is divided into variable-size sections.
2. For the paging operating system is accountable. For segmentation compiler is accountable.
3. Page size is determined by hardware. Here, the section size is given by the user.
4. It is faster in comparison of segmentation. Segmentation is slow.
5. Paging could result in internal fragmentation. Segmentation could result in external fragmentation.
6. In paging, logical address is split into that page number and page offset. Here, logical address is split into section number and section offset.
7. Paging comprises a page table which encloses the base address of every page. While segmentation also comprises the segment table which encloses the segment number and segment offset.
8. A page table is employed to keep up the page data. Section Table maintains the section data.
9. In paging, operating system must maintain a free frame list. In segmentation, the operating system maintains a list of holes in the main memory.
10. Paging is invisible to the user. Segmentation is visible to the user.
11. In paging, processor needs page number, offset to calculate the absolute address. In segmentation, the processor uses segment number, and offset to calculate the full address.

85. Write a definition of  Associative Memory and  Cache Memory? 

S.No.

Associative Memory

Cache Memory

1 A memory unit accessed by content is called associative memory. Fast and small memory is called cache memory.
2 It reduces the time required to find the item stored in memory. It reduces the average memory access time.
3 Here data is accessed by its content. Here, data are accessed by their address.
4 It is used where search time is very short. It is used when a particular group of data is accessed repeatedly.
5 Its basic characteristic is its logic circuit for matching its content. Its basic characteristic is its fast access

86. What is “Locality of reference”?

The locality of reference refers to a phenomenon in which a computer program tends to access the same set of memory locations for a particular time period. In other words, Locality of Reference refers to the tendency of the computer program to access instructions whose addresses are near one another.

87. Write down the advantages of virtual memory?

  • A higher degree of multiprogramming.
  • Allocating memory is easy and cheap
  • Eliminates external fragmentation
  • Data (page frames) can be scattered all over the PM
  • Pages are mapped appropriately anyway
  • Large programs can be written, as the virtual space available is huge compared to physical memory.
  • Less I/O required leads to faster and easy swapping of processes.
  • More physical memory is available, as programs are stored on virtual memory, so they occupy very less space on actual physical memory.
  • More efficient swapping

88. How to calculate performance in virtual memory?

The performance of virtual memory of a virtual memory management system depends on the total number of page faults, which depend on “paging policies” and “frame allocation”.

Effective access time = (1-p) x Memory access time + p x page fault time

89. Write down the basic concept of the file system?

A file is a collection of related information that is recorded on secondary storage. Or file is a collection of logically related entities. From the user’s perspective, a file is the smallest allotment of logical secondary storage. 

90. Write the names of different operations on file?

Operation on file:

  • Create
  • Open
  • Read
  • Write
  • Rename
  • Delete
  • Append
  • Truncate
  • Close

91. Define the term Bit-Vector?

A Bitmap or Bit Vector is a series or collection of bits where each bit corresponds to a disk block. The bit can take two values: 0 and 1: 0 indicates that the block is allocated and 1 indicates a free block.

92. What is a File allocation table?

FAT stands for File Allocation Table and this is called so because it allocates different files and folders using tables. This was originally designed to handle small file systems and disks. A file allocation table (FAT) is a table that an operating system maintains on a hard disk that provides a map of the cluster (the basic units of logical storage on a hard disk) that a file has been stored in.

93. What is rotational latency?

Rotational Latency: Rotational Latency is the time taken by the desired sector of the disgeek to rotate into a position so that it can access the read/write heads. So the disk scheduling algorithm that gives minimum rotational latency is better.

94. What is seek time?

Seek Time: Seek time is the time taken to locate the disk arm to a specified track where the data is to be read or written. So the disk scheduling algorithm that gives a minimum average seek time is better.

Operating System Interview Questions

Operating System (OS) is Software that facilitates computer software to communicate and operate computer hardware with the computer software. An operating system acts as a GUI between the User and the computer System. In Other words, an OS acts as an intermediary between the user and the computer hardware, managing resources such as memory, processing power, and input/output operations. Here some examples of popular operating systems include Windows, MacOS, Linux, Android etc.

In this article, we provide you with the top 100+ OS interview questions with answers that cover everything from the basics of OS architecture to advanced operating systems concepts such as file systems, scheduling algorithms, and multithreading. Whether you are a fresher or an experienced IT professional, this article gives you all the confidence you need to ace your next OS interview.

Operating System Interview Questions

Table of Content

  • Basics OS Interview Questions
  • Intermediate OS Interview Questions
  • Advanced OS Interview Questions

Similar Reads

Basics OS Interview Questions

1. What is a process and process table?...

Intermediate OS Interview Questions

61. Write a difference between a user-level thread and a kernel-level thread?...

Advanced OS Interview Questions

95. What is Belady’s Anomaly?...

Conclusion

In conclusion, the field of operating systems is a crucial aspect of computer science, and a thorough understanding of its concepts is essential for anyone looking to excel in this area. By reviewing the Top 2024 100+ operating systems interview questions we have compiled, you can gain a deeper understanding of the key principles and concepts of OS and be better prepared to tackle any interview questions that may come your way. Remember to study and practice regularly, and use these questions as a starting point to delve deeper into the complex world of operating systems. With dedication and hard work, you can become an expert in this field and succeed in any OS-related job or interview....