Operating System Interview Questions and Answers
by Bharathkumar, on Sep 10, 2022 11:11:09 PM
Q1. What is an operating system?
An operating system is a program that acts as an intermediary between the user and the computer hardware. The purpose of an OS is to provide a convenient environment in which user can execute programs in a convenient and efficient manner.
Q2. What is kernel?
Kernel is the core and essential part of computer operating system that provides basic services for all parts of OS.
Q3. What is difference between micro kernel and macro kernel?
Micro kernel is a kernel which run services those are minimal for operating system performance. In this kernel all other operations are performed by processor.
Macro Kernel is a combination of micro and monolithic kernel. In monolithic kernel all operating system code is in single executable image.
Q4. What is demand paging?
Demand paging is referred when not all of a process’s pages are in the RAM, then the OS brings the missing(and required) pages from the disk into the RAM.
Q5. What are the different operating systems?
- Batched operating systems
- Multi-programmed operating systems
- timesharing operating systems
- Distributed operating systems
- Real-time operating systems
Q6. What are the basic functions of an operating system?
Operating system controls and coordinates the use of the hardware among the various applications programs for various uses. Operating system acts as resource allocator and manager. Also operating system is control program which controls the user programs to prevent errors and improper use of the computer. It is especially concerned with the operation and control of I/O devices.
Q7. What are the advantages of a multiprocessor system?
With an increased number of processors, there is considerable increase in throughput. It can also save more money because they can share resources. Finally, overall reliability is increased as well.
Q8. What are real-time systems?
Real-time systems are used when rigid time requirements have been placed on the operation of a processor. It has well defined and fixed time constraints.
Q9. What is virtual memory?
Virtual memory is a memory management technique for letting processes execute outside of memory. This is very useful especially is an executing program cannot fit in the physical memory.
Q10. What is dead lock?
Deadlock is a situation or condition where the two processes are waiting for each other to complete so that they can start. This result both the processes to hang.
Q11. What is a process?
A program in execution is called a process.
Processes are of two types:
1. Operating system processes
2. User processes
Q12. What are the states of a process?
Q13. What is Throughput, Turnaround time, waiting time and Response time?
Throughput number of processes that complete their execution per time unit
Turnaround time amount of time to execute a particular process
Waiting time amount of time a process has been waiting in the ready queue
Response time amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
Q14. What is Memory-Management Unit (MMU)?
Hardware device that maps virtual to physical address. In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory.
->The user program deals with logical addresses; it never sees the real physical addresses
Q15. What is a trap and trapdoor?
Trapdoor is a secret undocumented entry point into a program used to grant access without normal methods of access authentication. A trap is a software interrupt, usually the result of an error condition.
Q16. When is a system in safe state?
The set of dispatchable processes is in a safe state if there exists at least one temporal order in which all processes can be run to completion without resulting in a deadlock.
Q17. Explain the concept of the Distributed systems?
Distributed systems work in a network. They can share the network resources, communicate with each other.
Q18. What is semaphore?
Semaphore is a variable, whose status reports common resource, Semaphore is of two types one is Binary semaphore and other is Counting semaphore.
Q19. What is context switching?
Transferring the control from one process to other process requires saving the state of the old process and loading the saved state for new process. This task is known as context switching.
Q20. What is a thread?
A thread is a program line under execution. Thread sometimes called a light-weight process, is a basic unit of CPU utilization; it comprises a thread id, a program counter, a register set, and a stack
Q21. What is process synchronization?
A situation, where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is called race condition. To guard against the race condition we need to ensure that only one process at a time can be manipulating the same data. The technique we use for this is called process synchronization.
Q22. What is thrashing?
It is a phenomenon in virtual memory schemes when the processor spends most of its time swapping pages, rather than executing instructions. This is due to an inordinate number of page faults.
Q23. What is cache memory?
Cache memory is random access memory (RAM) that a computer microprocessor can access more quickly than it can access regular RAM. As the microprocessor processes data, it looks first in the cache memory and if it finds the data there (from a previous reading of data), it does not have to do the more time-consuming reading of data from larger memory.
Q24. What is logical and physical addresses space?
Logical address space is generated from CPU; it bound to a separate physical address space is central to proper memory management. Physical address space is seen by the memory unit. Logical address space is virtual address space. Both these address space will be same at compile time but differ at execution time.
Q25. Differentiate between Complier and Interpreter?
An interpreter reads one instruction at a time and carries out the actions implied by that instruction. It does not perform any translation. But a compiler translates the entire instructions
Q26. What is cache-coherency?
In a multiprocessor system there exist several caches each may containing a copy of same variable A. Then a change in one cache should immediately be reflected in all other caches this process of maintaining the same value of a data in all the caches s called cache-coherency.
Q27. What is fragmentation? Tell about different types of fragmentation?
When many of free blocks are too small to satisfy any request then fragmentation occurs. External fragmentation and internal fragmentation are two types of fragmentation. External Fragmentation happens when a dynamic memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively used. Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the allowed sizes of allocated blocks.
Q28. What is a long term scheduler & short term schedulers?
Long term schedulers are the job schedulers that select processes from the job queue and load them into memory for execution. The short term schedulers are the CPU schedulers that select a process from the ready queue and allocate the CPU to one of them.
Q29. Explain the meaning of mutex.
Mutex is the short form for Mutual Exclusion object. A mutex allows multiple threads for sharing the same resource. The resource can be file. A mutex with a unique name is created at the time of starting a program. A mutex must be locked from other threads, when any thread that needs the resource. When the data is no longer used / needed, the mutex is set to unlock.
Q30. What are necessary conditions for dead lock?
- Mutual exclusion (where at least one resource is non-sharable)
- Hold and wait (where a process holds one resource and waits for other resource)
- No preemption (where the resources cant be preempted)
- Circular wait (where p[i] is waiting for p[j] to release a resource. i= 1,2, nj=if (i!=n) then i+1else 1 )