Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • +1, only answer that adds anything to the accepted one. Nice description of the "segmentation" history. Fun fact: x86 actually still has segment limits in 32bit protected mode (with or without paging (virtual memory) enabled), so instructions that access memory can generate #PF(fault-code) (page fault) or #GP(0) ("If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit."). 64bit mode drops segment limit checks, since OSes just used paging instead, and a flat memory model for user-space. Commented Jan 28, 2016 at 6:44
  • Actually, I believe most OSes on x86 use segmented pagination: a bunch of big segments inside a flat, paged address space. This is how you protect and map kernel memory into each address space: rings (protection levels) are linked to segments, not pages Commented Jan 28, 2016 at 14:22
  • Also, on NT (but I would love to know if on most Unixes is the same!) "segmentation fault" could happen quite often: there is a 64k protected segment at the beginning of the user space, so dereferencing a NULL pointer raises a (proper?) segmentation fault Commented Jan 28, 2016 at 14:24
  • 1
    @LorenzoDematté Yes, all-or-nearly-all modern Unixes will leave a chunk of permanently unmapped addresses at the beginning of the address space in order to catch NULL dereferences. It can be quite large -- on 64-bit systems, in fact, it might be four gigabytes, so that accidental truncation of pointers to 32 bits will be caught promptly. However, segmentation in the strict x86 sense is barely used at all; there is one flat segment for user space and one for the kernel, and maybe a couple for special tricks like getting some use out of FS and GS. Commented Jan 28, 2016 at 16:37
  • 1
    @LorenzoDematté NT uses exceptions rather than signals; in this case STATUS_ACCESS_VIOLATION. Commented Jan 28, 2016 at 16:39