home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!hpa
- From: hpa@casbah.acns.nwu.edu (H. Peter Anvin N9ITP)
- Subject: Re: Does Linux use segmentation?
- Message-ID: <1992Nov11.021246.3563@news.acns.nwu.edu>
- Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
- Reply-To: hpa@nwu.edu (H. Peter Anvin)
- Organization: You must be kidding!
- References: <1992Nov11.011359.27473@cbnewse.cb.att.com> <1dpov0INNqcu@agate.berkeley.edu>
- Date: Wed, 11 Nov 1992 02:12:46 GMT
- Lines: 56
-
- In article <1dpov0INNqcu@agate.berkeley.edu> of comp.os.linux,
- curtis@cs.berkeley.edu (Curtis Yarvin) writes:
- > In article <1992Nov11.011359.27473@cbnewse.cb.att.com> sph1@cbnewse.cb.att.com (stephen.p.hill) writes:
- > >
- > >I get the impression that Linux uses combined paging and
- > >segmentation, in fact that nearly all modern OSs use
- > >the combination. Is this true?(the part about Linux)
- >
- > Like most modern OSs, Linux uses paging and avoids segmentation
- > (for the most part) like the plague. This is because modern
- > processors do not have segmentation, and it does not fit well
- > with modern operating systems design.
- >
-
- However, the 386/486 DOES support segmentation. REAL segmentation, not the
- crock used by the 8086/80286 to get around the 64K limitation, but
- segmentation used for object isolation. It would be feasible, for example,
- to have open() assign a segment descriptor and map a whole file into a
- segment (using paging). Regular pointer constructs would then be used to
- access the file (on disk) and close() would unmap the file. This idea was
- incorporated in MULTICS, for example.
-
- Under no circumstances would you need to use different segment descriptors
- to access different part of the same data element or structure. That
- defeats the purpose of segmentation, and all you have left is a hideously
- complex memory model. That is, array1[] and array2[] can be in different
- segments (a pointer would include the descriptor and an offset), but
- array1[0] and array1[1000000] should differ only by their offsets. No
- pointer arithmetric should ever involve the segment descriptors, except
- comparison. (array1 != array2 is TRUE, array2 - array1 = ERROR)
-
- On the other hand, this technique is not the way UNIX and C likes to do it.
- They prefer a flat virtual memory space, and use system calls for file
- access. This is also the way Linux does it... almost. The Linux memory
- model uses one set of segment descriptors for user mode and another for
- kernel mode. When running in user mode, all segment registers contain the
- user mode descriptors. In kernel mode, CS, DS, ES and SS contain kernel
- mode descriptors, while FS contains the user mode data descriptor, so the
- kernel easily can access user space data.
-
- > You will hear the word "segment" kicked around in a lot of
- > places and a lot of different ways; be careful. Just because
- > you have, say, a "text segment" doesn't mean you use
- > segmentation.
-
- Agreed. "Text portion" would be more accurate, but I assume this term came
- to UNIX from Multics, which *did* support segmentation. By the way, does
- anyone know what BSS stands for? I have only seen "for historical
- reasons"...
-
- /hpa
- --
- INTERNET: hpa@nwu.edu TALK: hpa@casbah.acns.nwu.edu
- BITNET: HPA@NUACC IBMNET: 16331@IBMX400
- HAM RADIO: N9ITP NeXTMAIL: hpa@lenny.acns.nwu.edu
- rm -rf /msdos /windows /win-nt
-