Cavium Networks Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: Written Test
In computing, a segmentation fault (often shortened to segfault) or access violation is a fault raised by hardware with memory protection, notifying an operating system (OS) about a memory access violation; on x86 computers this is a form of general protection fault. The OS kernel will in response usually perform some corrective action, generally passing the fault on to the offending process by sending the process a signal. Processes can in some cases install a custom signal handler, allowing them to recover on their own,[1] but otherwise the OS default signal handler is used, generally causing abnormal termination of the process (a program crash), and sometimes a core dump.
first segmentation fault :-
- rahul August 13, 2014if a CPU trying to access memory for which it doesnot have permission or invalid it traps with an exception of page fault and signal SIGSEGV is sent to the process which tries this and default action for SIGSEGV is to kill the process.
for pagefault:
when cpu looking for a page which is not in TLB (temporary look aside buffer)
then a pagefault occurs which means page need to be loaded back in memory.
this is done as follows :
pagefault handler takes care of it ,
it checks if current page is dirty (if date need to be written back to memory using D bit in flags of TLB entry.
1. first find the location of requested page in page table (PTE which is maintained in software )
2. to load that page in TLB (tlb refill occurs depending on archiecture of cpu in MIPS it replaces a random entry and brings requested page.
3. if cahing is needed do that for current page (check if C flsag was set )
return from the handler and execute current instruction.