Unix Interview Technical Questions with answers

1) What is a shell?
A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. The shell converts them to system calls to the OS or forks off a process to execute the command. System call results and other information from the OS are presented to the user through an interactive interface. Commonly used shells are sh,csh,ks etc.

Unix Interview Technical Questions with answers


2)What is the difference between Swapping and Paging?
Swapping: Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems.
Paging: Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly.



3)What is major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management?
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.



4) In what way the protection fault handler concludes?
After finishing the execution of the fault handler, it sets the modify and protection bits and clears the copy on write bit. It recalculates the process-priority and checks for signals.



5)How the Kernel handles both the page stealer and the fault handler?
The page stealer and the fault handler thrash because of the shortage of the memory. If the sum of the working sets of all processes is greater that the physical memory then the fault handler will usually sleep because it cannot allocate pages for a process. This results in the reduction of the system throughput because Kernel spends too much time in overhead, rearranging the memory in the frantic pace.



6)Name two paging states for a page in memory?
The two paging states are:
    The page is aging and is not yet eligible for swapping,
    The page is eligible for swapping but not yet eligible for reassignment to other virtual address space.



7)What are the phases of swapping a page from the memory?
    Page stealer finds the page eligible for swapping and places the page number in the list of pages to be swapped.
    Kernel copies the page to a swap device when necessary and clears the valid bit in the page table entry, decrements the pfdata reference count, and places the pfdata table entry at the end of the free list if its reference count is 0.



8) What is page fault? Its types?
Page fault refers to the situation of not having a page in the main memory when any process references it. There are two types of page fault :
    Validity fault,
    Protection fault.



9)In what way the Fault Handlers and the Interrupt handlers are different?
Fault handlers are also an interrupt handler with an exception that the interrupt handlers cannot sleep. Fault handlers sleep in the context of the process that caused the memory fault. The fault refers to the running process and no arbitrary processes are put to sleep.



10)What is validity fault?
If a process referring a page in the main memory whose valid bit is not set, it results in validity fault. The valid bit is not set for those pages:
that are outside the virtual address space of a process,
    that are the part of the virtual address space of the process but no physical address is assigned to it.



11) What does the swapping system do if it identifies the illegal page for swapping?
If the disk block descriptor does not contain any record of the faulted page, then this causes the attempted memory reference is invalid and the kernel sends a "Segmentation violation" signal to the offending process. This happens when the swapping system identifies any invalid memory reference.



12)How the Swapper works?
The swapper is the only process that swaps the processes. The Swapper operates only in the Kernel mode and it does not uses System calls instead it uses internal Kernel functions for swapping. It is the archetype of all kernel process.



13)What are the processes that are not bothered by the swapper? Give Reason.
    Zombie process: They do not take any up physical memory.
    Processes locked in memories that are updating the region of the process.
    Kernel swaps only the sleeping processes rather than the 'ready-to-run' processes, as they have the higher probability of being scheduled than the Sleeping processes.



14)What are the requirements for a swapper to work?
The swapper works on the highest scheduling priority. Firstly it will look for any sleeping process, if not found then it will look for the ready-to-run process for swapping. But the major requirement for the swapper to work the ready-to-run process must be core-resident for at least 2 seconds before swapping out. And for swapping in the process must have been resided in the swap device for at least 2 seconds. If the requirement is not satisfied then the swapper will go into the wait state on that event and it is awaken once in a second by the Kernel.



15)What are the criteria for choosing a process for swapping into memory from the swap device?
The resident time of the processes in the swap device, the priority of the processes and the amount of time the processes had been swapped out.



16)What are the criteria for choosing a process for swapping out of the memory to the swap device?
    The process's memory resident time,
    Priority of the process and
    The nice value.



17)What do you mean by nice value?
Nice value is the value that controls {increments or decrements} the priority of the process. This value that is returned by the nice() system call. The equation for using nice value is:
Priority = ("recent CPU usage"/constant) + (base- priority) + (nice value)
Only the administrator can supply the nice value. The nice() system call works for the running process only. Nice value of one process cannot affect the nice value of the other process.



18)What are the events done by the Kernel after a process is being swapped out from the main memory?
When Kernel swaps the process out of the primary memory, it performs the following:
    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,
    Kernel allocates the space for the swapping process in the swap device,
    Kernel locks the other swapping process while the current swapping operation is going on,
    The Kernel saves the swap address of the region in the region table.


19)Is the Process before and after the swap are the same? Give reason.
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.



20)What do you mean by u-area (user area) or u-block?
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.



21)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.
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.



22)What is Fork swap?
"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.


23)What is Expansion swap?
At the time when any process requires more memory than it is currently allocated, the Kernel performs Expansion swap. To do this Kernel reserves enough space in the swap device. Then the address translation mapping is adjusted for the new virtual address space but the physical memory is not allocated. At last Kernel swaps the process into the assigned space in the swap device. Later when the Kernel swaps the process into the main memory this assigns memory according to the new address translation mapping.


24)What are states that the page can be in, after causing a page fault?
    On a swap device and not in memory,
    On the free page list in the main memory,
    In an executable file,
    Marked "demand zero",
    Marked "demand fill"


25)In what way the validity fault handler concludes?
   It sets the valid bit of the page by clearing the modify bit.
    It recalculates the process priority.



26) At what mode the fault handler executes?
  At the Kernel Mode.


27) What do you mean by the protection fault?
Protection fault refers to the process accessing the pages, which do not have the access permission. A process also incur the protection fault when it attempts to write a page whose copy on write bit was set during the fork() system call.



28)For which kind of fault the page is checked first?
The page is first checked for the validity fault, as soon as it is found that the page is invalid (valid bit is clear), the validity fault handler returns immediately, and the process incur the validity page fault. Kernel handles the validity fault and the process will incur the protection fault if any one is present.



29)Define session?
A session is a collection of one or more process groups. A process establishes a new session by calling setsid function. This function returns process group id if OK.



30)What do you mean by signal?
 Signals are software interrupts. Signals provide a way of handling asynchronous events: a user at a terminal typing the interrupt key to stop a program or the next program in the pipeline terminating prematurely.



31)What is unix?
 UNIX is the most popular operating system on multi-user systems. This operating system originated as a single-user system. It started off on a cast-off DEC PDP-7 at Bell laboratories in 1969. Ken Thompson, with ideas and help from Dennis Ritchie, and others, wrote a small, general-purpose operating system.



31)Define message queue?
message queue Message queue is a linked list of messages. It is used to make a communication between the related or unrelated processes.



32)What is the use of break and continue statements?
 The continue statement suspends execution of all statements following it, and switches control to the top of the loop for the next iteration. The break statement, on the other hand, causes control to break out of the loop.



36. What is single users system?
The personal computer (PC) is a small, general-purpose system that can execute programs to perform a wide variety of tasks. The PC, however, was designed for use by one person at a time; that is, it is Single-User oriented with MS-DOS as the de facto standard operating system for this range of machines. Single user systems became very popular due to the low cost hardware and wide range of software available for these machines.



37)What is Kernel?
 Kernel is core part of unix o/s. It is a group of hundreds of system calls.



38) What are the different security features in Unix?
   Password protection
    File permissions
    Encryption.



39)What does the swapping system do if it identifies the illegal page for swapping?
 If the disk block descriptor does not contain any record of the faulted page, then this causes the attempted memory reference is invalid and the kernel sends a “Segmentation violation” signal to the offending process. This happens when the swapping system identifies any invalid memory reference.


40) How do you find out the current directory you’re in?
pwd



















Ad Inside Post

Comments system

Disqus Shortname