Operating System Interview Questions and Answers Part-2
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.
12. 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
13. 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.
14. What is virtual memory?
Virtual memory is hardware technique where the system appears to have more memory that it actually does. This is done by time-sharing, the physical memory and storage parts of the memory one disk when they are not actively being used.
15. 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.
16. 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.
17. What are necessary conditions for dead lock?
1. Mutual exclusion (where at least one resource is non-sharable)
2. Hold and wait (where a process holds one resource and waits for other resource)
3. No preemption (where the resources cant be preempted)
4. Circular wait (where p[i] is waiting for p[j] to release a resource. i= 1,2, n
j=if (i!=n) then i+1
else 1 )
18. 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.
19. 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.
20. 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