Interview Questions on OS - Memory Management

1. What is swapping

A process must be in memory to be executed. A process, however, can be swapped temporarily out of memory to a backing store and then brought back into memory for continued execution. This process is called swapping.

2. What is fragmentation?

fragmentation is a phenomenon in which storage space is used inefficiently, reducing capacity or performance.

3. Explain External fragmentation?

As processes are loaded and removed from memory, the free memory space is broken into little pieces. External fragmentation exists when there is enough total memory space to satisfy a request, but the available spaces are not contiguous.

4. Explain Internal fragmentation?

Consider a multiple-partition allocation scheme with a hole of 18,464 bytes. Suppose that the next process requests 18,462 bytes. If we allocate exactly the requested block, we are left with a hole of 2 bytes. The overhead to keep track of this hole will be substantially larger than the hole itself. The general approach to avoiding this problem is to break the physical memory into fixed-sized blocks and allocate memory in units based on block size. With this approach, the memory allocated to a process may be slightly larger than the requested memory. The difference between these two numbers is internal fragmentation.

5. What is paging?

Paging is a memory-management scheme that permits the physical address space of a process to be noncontiguous. Paging avoids the considerable problem of fitting memory chunks of varying sizes onto the backing store.

6. What is frame?

Breaking main memory into fixed number of blocks called frames.

7. What is page?

Breaking logical memory into blocks of same size is page.

Memory Management

Interview Questions on OS - Virtual Memory

1. What is virtual memory?

Virtual memory is memory management technic which is used to execute the process which has more than actual memory size.

2. What is Demand Paging?

It is memory management technique used in virtual memory such that page will not load into the memory until it is needed.

3. What are all page replacement algorithms?

1. FIFO(First in First out)
2. Optimal Page Replacement
3. LRU(Least-Recently-used)

4. Which page replacement algorithm will have less page fault rate?

Optimal Page Replacement

5. What is thrashing?

It is situation that CPU spends more time on paging than executing.


Virtual Memory

Interview Questions on OS - Deadlock

1. what is deadlock?

Deadlock is a situation that when two or more process waiting for each other and holding the resource which is required by another process.

2. What are the necessary conditions to occur deadlock?

Mutual exclusion: At least one resource must be held in a nonsharable mode. that is, only one process at a time can use the resource. If another process requests that resource, the requesting process must be delayed until the resource has been released.
Hold and wait: A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
No preemption: Resources cannot be preempted.; that is, a resource can be released only voluntarily by the process holding it, after that process has completed its task.
Circular wait: A set {P$, Pi, ..., Pn\ of waiting processes must exist such that P-0 is waiting for a resource held by P\, P\ is waiting for a resource held by P?, •••, P.,--i is waiting for a resource held by Pn, and P,, is waiting for a resource held by Pn.

3. Explain about resource allocation graph?

Deadlocks can be described more precisely in terms of a directed graph called a system resource-allocation graph. If the graph contains no cycles, then no process in the system is deadlocked. If the graph does contain a cycle, then a deadlock may exist.

4. What are the methods to handle the dead locks?

1. We can use a protocol to prevent or avoid deadlocks, ensuring that the system will never enter a deadlock state.
2. We can allow the system to enter a deadlock state, detect it, and recover.
3. We can ignore the problem altogether and pretend that deadlocks never occur in the system.
The third solution is the one used by most operating systems

5. What is Bankers Algorithm.

it is an algorithm which used in a banking system to ensure that the bank never allocated its available cash in such a way that it could no longer satisfy the needs of all its customers.


Deadlock

Interview Questions on OS - Cpu Scheduler

1. What are all the scheduling algorithms?

1. FCFS(FirstCome First Serve)
2. SJF(Shortest Job First)
3. Round robin
4. Priority Scheduling algorithms

2. Explain FCFS(First Come First Served)?

The process that requests the CPU first is allocated the CPU first. The code for FCFS scheduling is simple to write and understand.

3. Explain SJF(Shortest Job First)?

The process which has the less burst time execute first. If both process have same burst time then FCFS will be used.

4. Explain Round Robin?

The round-robin (RR) scheduling algorithm is designed especially for timesharing systems. CPU switch between the processes based on a small unit of time called time slice.

5. Explain Priority Scheduling algorithm?

CPU is allocated to the process with the highest priority.

6. Which algorithm gives minimum average waiting time?

SJF(Shortest Job First)

7. What is CPU utilization?

We want to keep the CPU as busy as possible. Conceptually, CPU utilization can range from 0 to 100 percent. In a real system, it should range from 40 percent (for a lightly loaded system) to 90 percent.

8. What is Throughput?

The amount of work is being done by the CPU. One unit of work is the number of processes that are completed per unit time, called throughput

9. What is Turnaround time.

The interval from the time of submission of a process to the time of completion is the turnaround time

10. What is waiting time?

Waiting time is the sum of the periods spent waiting in the ready queue.

11. What is Response time?

the time from the submission of a request until the first response is produced.


Cpu Scheduler

Interview Questions on OS - Process

1. What is a Process ?

A program under execution is process

2. What are the process states?

New: The process is being created.
Running: Instructions are being executed.
Waiting: The process is waiting for some event to occur (such as an I/O completion or reception of a signal).
Ready: The process is waiting to be assigned to a processor.
Terminated: The process has finished execution.

3. What is fork() ?

Fork() is a system call which is used to create a separate, duplicate process.

4. What is exex() ?

exex () is a system call which id used to replace the entire process.

5. What is Process Control Block?

Each process is represented in the operating system by a process control block. It contains many pieces of information associated with a specific process, including these:
1. Process state
2. Program counter
3. CPU registers
4. Memory-management information.

6. What is Context switch?

Switching the CPU to another process requires performing a state save of the current process and a state restore of a different process. This task is known as a context switch.

7. What do you know about Inter process Communication

interprocess communication (IPC) mechanism that will allow them to exchange data and information.
There are two fundamental models of interprocess communication:
1. shared memory
2. message passing

8. What is Socket?

A socket is defined as an endpoint for communication. A socket is identified by an IP address concatenated with a port number.

9. What is Remote Procedure calls?

This mechanism provides Communication of the system over the network.

10. What is Remote Method Invocation?

It is java feature to provide similar to RPC.

11. What is Critical Section problem?

Each process has a segment of code, called a critical section, in which the process may be changing common variables, updating a table, writing a file, and so on. The important feature of the system is that, when one process is executing in its critical section, no other process is to be allowed to execute in its critical section.

12. What is semaphore?

It is a flag variable which is used whether process is executing in critical section or not.

13 . What is synchronization?

Process of controlling multiple access to one resource is called synchronization.

Process

Interview Questions on OS - Threads

1. What is a Thread?

A thread is a basic unit of CPU utilization. If a process has multiple threads of control, it can perform more than one task at a time.

2. What are the benefits of multithreading?

Responsiveness. Increase responsiveness to the user.
Resource sharing. threads share the memory.

3. What is fork() ?

Fork() is a system call which is used to create a separate, duplicate process.

4. What is exex() ?

exex () is a system call which id used to replace the entire process.

5. What are Multithreading Models?

Many-to-One Model : The many-to-one model (Figure 4.2) maps many user-level threads to one kernel thread
One-to-One Model: The one-to-one model (Figure 4.3) maps each user thread to a kernel thread.
Many-to-Many Model: The many-to-many model (Figure 4.4) multiplexes many user-level threads toa smaller or equal number of kernel threads.

6. What is Thread cancellation?

Thread cancellation is the task of terminating a thread before it has completed.

7. What is the use of the signal?

A signal is used in UNIX systems to notify a process that a particular event has occurred.

8. What is thread pool?

Thread Pool is a container which holds multiple threads.
The general idea behind a thread pool is to create a number of threads at process startup and place them into a pool, where they sit and wait for work. When a server receives a request, it awakens a thread from this pool—if one is available—and passes it the request to service. Once the thread completes its service, it returns to the pool and awaits more work. If the pool contains no available thread, the server waits until one becomes free.

9. What is the use of Thread Pool?

Servicing a request with an existing thread is usually faster than waiting to create a thread.


Threads

Interview Questions on OS - Basics

1. What is an Operating System?

An operating system is set of programs that acts as an interface between the user and the hardware

2. What is Clustered System?

Clustered computers share the storage and are linked via a local-area network (LAN). Clustering is usually used to provide high-availability service.(even if one fails another one will manage the storage)

3. What is Dual Mode Operation?

In order to ensure the proper execution of the operating system, we must be able to distinguish between the execution of OS code and user code. we need two separate modes of operation:
1. user mode.
2. kernel mode.

4. What is Timer?

We must prevent a user program from getting stuck in an infinite loop. To accomplish this goal, we can use a timer.

5. What is cache?

Information is normally kept in some storage system . When it is used, it is copied into a faster storage system called the cache. When we need a particular piece of information, we first check whether it is in the cache. If it is, we use the information directly from the cache; if it is not,we use the information from the source, putting a copy in the cache under the assumption that we will need it again soon.

6. What is System Call?

System calls are routines to perform a particular operation and provides interface to the services. These calls are generally written in C and C++ .

7. What is kernel?

Kernel is the core of the operating system which acts as an interface between hardware and software.


Basics