Memory Fault

From COMP15212 Wiki
On path: Exceptions 1: Exceptions • 2: Reset • 3: System Calls • 4: Software Exceptions • 5: Emulator traps • 6: Memory Fault • 7: Interrupts • 8: Unix Signals
Depends on ExceptionsPagingMemory Segmentation

A computer’s (main) memory can be read or written by software. However, under some circumstances the memory system will indicate an exception instead, indicating that the requested operation cannot be completed … at least at this time. Instead it aborts.

There are a few typical causes for this.

  • Privilege violation – e.g. where a user application tries to get at operating system space.
  • Page faults indicate there is no physical memory at that (virtual) address.
  • The operation has become stalled and timed out (typically associated with I/O devices).
  • The memory has been corrupted and detected this (e.g. parity check).

Note that “memory” here may include access to I/O peripheral devices and interfaces which are often memory mapped into the address space.

As may be deduced there are different causes which can occur in different stages of the memory cycle. These may trap in the same, or similar, ways and need sorting out by the operating system. This exception can be seen as a sort of system call although it might not happen consistently.

Example: a LOAD instruction addresses a page which is found to be absent during memory mapping; the MMU triggers an abort which calls the paging process. The paging process returns to the faulting instruction, which now completes successfully. The next time the same LOAD executes the page is found and no exception occurs.

Memory faults are therefore ‘called’ by a combination of hardware and software.


When a memory fault has occurred the cause must be determined and the appropriate action decided. Examples of the sort of causes and the appropriate actions might include:

  • Applications code tries to write to OS memory: segmentation fault – terminate process.
  • Applications code tries to read from an absent page: page fault - fetch page from disk and ‘return’ to retry operation.
  • I/O routine in OS times out during peripheral access: log error, maybe retry by ‘returning’ appropriate code to software.
  • Memory parity fault: depends on system; may be possible to restore/recreate the memory contents, may have to terminate the process.

Example?: if you haven’t managed to cause a segmentation fault yet you can’t have been trying hard enough!


Also refer to: Operating System Concepts, 10th Edition: Chapter 10.2.1, pages 393-396