John McMain
John McMain

Reputation: 89

Difference between an interrupt and a page fault

In operating systems, what is the difference between a page fault and an interrupt? I know that page fault is when the MMU(Memory Management Unit) cannot find the allocated location in the virtual memory

Upvotes: 7

Views: 7064

Answers (2)

user3344003
user3344003

Reputation: 21667

Processors are designed to handle two special types of events.

  1. Exceptions
  2. Interrupts

Both are handled in the same way. Each exception and interrupt known to the CPU has a number. This number is used as an index into a dispatch table of handler routines maintained by the operating system. When the exception or interrupt occurs, the CPU enters kernel mode then locate the corresponding handler routine and invokes it. (Hopefully, the handler will returns to whatever mode the system was in prior to the event).

The difference between an exception and an interrupt is that the former are triggered by the instruction stream and the latter are triggered by events independent of the instruction stream.

Exceptions fall into two categories: faults and traps. The former allow the current instruction to be restarted while the latter do not.

A page fault is then an exception.

Upvotes: 14

haltode
haltode

Reputation: 618

Page fault and interrupts are two distincts concepts.

From the OSdev wiki:

A page fault exception is caused when a process is seeking to access an area of virtual memory that is not mapped to any physical memory, when a write is attempted on a read-only page, when accessing a PTE or PDE with the reserved bit or when permissions are inadequate.

And concerning interrupts:

An interrupt is a signal from a device, such as the keyboard, to the CPU, telling it to immediately stop whatever it is currently doing and do something else. For example, the keyboard controller sends an interrupt when a key is pressed.

So basically, a page fault is an error, an interrupt is a signal and you can use an interrupt to detect a page fault.

For more information on the subject:

Upvotes: 1

Related Questions