0

When a user-space application incurs a page fault, is the Operating System (OS) automatically invoked upon detection of the fault or must the OS be invoked manually?

For Linux and x86, I understand there are checks for privilege level of process invoking the interrupt/exception handler, but am confused as to whether failing these checks automatically invoke the OS to handle the page fault or not.

ballsmahoney
  • 141
  • 1
  • 6
  • 1
    Page faults are handled entirely in the hardware and OS, user-mode code never detects them. – Barmar Oct 06 '22 at 00:59
  • So upon a page fault being incurred, is the fault handler automatically invoked? Is this implemented in hardware or software (or a combination)? Does the privilege switch (from ring 3 to 0) also occur simultaneously? Thank you. – ballsmahoney Oct 06 '22 at 01:05
  • 1
    [Page Fault Exception Handler](https://www.oreilly.com/library/view/understanding-the-linux/0596005652/ch09s04.html) – Barmar Oct 06 '22 at 01:06
  • Thank you for the link. From that, what confuses me is how the do_page_fault() function even gets invoked (for example, is it hardwired to occur upon a page fault)? – ballsmahoney Oct 06 '22 at 01:09
  • 1
    It's from the operating system's interrupt handler. – Barmar Oct 06 '22 at 01:09
  • 1
    All hardware interrupts are handled by the OS. – Barmar Oct 06 '22 at 01:11
  • So the interrupt signal that is generated by hardware causes a privilege switch from user-space to kernel-space (if necessary), then begins execution of the respective interrupt/exception handler? – ballsmahoney Oct 06 '22 at 01:13
  • 1
    Yes, that's not specific to page faults, all interrupts work like that. There must be an earlier chapter in that book that explains this. – Barmar Oct 06 '22 at 01:14

0 Answers0