I'm reading "Understanding Linux Kernel 3rd edition" and it starts talking about memory segments. It says that a logical address is:

Included in the machine language instructions to specify the address of an oper- and or of an instruction. This type of address embodies the well-known 80 × 86 segmented architecture that forces MS-DOS and Windows programmers to divide their programs into segments. Each logical address consists of a segment and an offset (or displacement) that denotes the distance from the start of the seg- ment to the actual address.

Well, for a x86 architecture, the instructions must fit a register, that is, they must be int he 32-bits format.

The book says then that logical addresses are formed by the segment identifier (16 bits) and the offset, which is 32 bits. Since the logical address is included in the machine language instructions, it does not makes sense that it is formed by 16 bits + 32 bits. So I presume that's the following:

The kernel code is a bunch of instructions in the 32-bit format, that is, its either instructions or it points to 32-bit addresses. Obviously a machine instruction can't be of length 16+32, therefore what happens is that the kernel chooses a segment to work with, and then stores the segment selector in the register it wants, so all the addresses given by the offset will fall inside that segment. However, I see it as a redundant form of paging, and it does not make much sense. What if the segment is of length 1mb and the offset refers to a address much greater than that? It makes sense if the code refers to addresses near it, but I don't get the necessity of segmentation here.

  • 1
    $\begingroup$ Yes, segmentation is somewhat redundant to paging (but different, some protection mechanism more tied to applications than to the user/super modes), and got eventually deprecated in the AMD 64bits mode. There are code, data, stack segments. They were far more used in the 8086 and 80286 which had 16bits registers and many programs exceeded the dreadful 64kB barrier. $\endgroup$ – TEMLIB Feb 7 '16 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.