4 ms·
The kernel receives the trap because the address is either invalid or has the wrong permissions. The exact details of how this could happen are architecture-dep
by geofft 11y ago
The kernel receives the trap because the address is either invalid or has the wrong permissions. The exact details of how this could happen are architecture-dependent, and indeed, the UNIX use of the phrase "Segmentation fault" instead of "Page fault" is a holdover from platforms which used segmentation instead of paging. (Windows 9x's "This program has performed an illegal operation" dialog box gave it the much more accurate name of an "invalid page fault"; I think current Windows goes with "access violation".)
The CPU doesn't really know about processes. (Some CPUs have features to manage "tasks", but they are not commonly used 1-to-1 with actual processes, largely for efficiency/performance reasons as I understand it.) The OS tells the CPU that any time it hits a page fault, it should start running code at this address with kernel privilege; this configuration itself also requires kernel privilege. Then it drops privileges and jumps to user code. When the user code makes an invalid memory access, the CPU follows the previous configuration about what to do in the case of an error. That runs a kernel function that delivers the signal (which is an entirely UNIX-specific concept).
- deleted 11y ago[deleted]
- asveikau 11y agoI'm amused when HN replies take this sort of lecturing tone and I am already well familiar with the subject matter.
- geofft 11y agoHaha. I wasn't quite sure if you were asking because you were familiar or unfamiliar, but I figured I'd post it anyway for the benefit of other people clicking through the thread (e.g. GP, who sees replies to descendant comments). Don't read it as a reply to you personally :P
- deleted 11y ago[deleted]