Friday 21 September 2012

UNIX Interview Questions-4


31. What is major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management?
Ans:
Historic Unix uses Swapping – entire process is transferred to the main memory from the swap device, whereas the Unix System V uses Demand Paging – only the part of the process is moved to the main memory. Historic Unix uses one Swap Device and Unix System V allow multiple Swap Devices.

32. What is the main goal of the Memory Management?
Ans: It decides which process should reside in the main memory, Manages the parts of the virtual address space of a process which is non-core resident, Monitors the available main memory and periodically write the processes into the swap device to provide more processes fit in the main memory simultaneously.

33. What is a Map?
Ans: A Map is an Array, which contains the addresses of the free space in the swap device that are allocatable resources, and the number of the resource units available there. This allows First-Fit allocation of contiguous blocks of a resource. Initially the Map contains one entry – address (block offset from the starting of the swap area) and the total number of resources. Kernel treats each unit of Map as a group of disk blocks. On the allocation and freeing of the resources Kernel updates the Map for accurate information.

34. What scheme does the Kernel in Unix System V follow while choosing a swap device among the multiple swap devices?
Ans:
Kernel follows Round Robin scheme choosing a swap device among the multiple swap devices in Unix System V.

35. What is a Region?
Ans: A Region is a continuous area of a process’s address space (such as text, data and stack). The kernel in a ‘Region Table’ that is local to the process maintains region. Regions are sharable among the process.

36. What are the events done by the Kernel after a process is being swapped out from the main memory?
Ans: When Kernel swaps the process out of the primary memory, it performs the following : 
1. Kernel decrements the Reference Count of each region of the process. If the reference count becomes zero, swaps the region out of the main memory.
2. Kernel allocates the space for the swapping process in the swap device.
3. Kernel locks the other swapping process while the current swapping operation is going on. 
4. The Kernel saves the swap address of the region in the region table.

37. Is the Process before and after the swap are the same? Give reason.
Ans: Process before swapping is residing in the primary memory in its original form. The regions (text, data and stack) may not be occupied fully by the process, there may be few empty slots in any of the regions and while swapping Kernel do not bother about the empty slots while swapping the process out. After swapping the process resides in the swap (secondary memory) device. The regions swapped out will be present but only the occupied region slots but not the empty slots that were present before assigning. While swapping the process once again into the main memory, the Kernel referring to the Process Memory Map, it assigns the main memory accordingly taking care of the empty slots in the regions.

38. What do you mean by u-area (user area) or u-block?
Ans: This contains the private data that is manipulated only by the Kernel. This is local to the Process, i.e. each process is allocated a u-area.

39. What are the entities that are swapped out of the main memory while swapping the process out of the main memory?
Ans: All memory space occupied by the process, process’s u-area, and Kernel stack are swapped out, theoretically. Practically, if the process’s u-area contains the Address Translation Tables for the process then Kernel implementations do not swap the u-area.

40. What is Fork swap?
Ans: fork( ) is a system call to create a child process. When the parent process calls fork() system call, the child process is created and if there is short of memory then the child process is sent to the read-to-run state in the swap device, and return to the user state without swapping the parent process. When the memory will be available the child process will be swapped into the main memory. 

No comments:

Post a Comment