home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / linux / 16310 < prev    next >
Encoding:
Text File  |  1992-11-10  |  3.3 KB  |  69 lines

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