segments and Unix

David DiGiacomo david at sun.uucp
Wed Nov 19 09:52:50 AEST 1986


In article <13802 at amdcad.UUCP> phil at amdcad.UUCP (Phil Ngai) writes:
>I'd like to propose something here. Have you ever spent a few days
>tracking down a bug caused by writing beyond the bounds of an array
>and trashing a vital data structure which only gets noticed many
>cycles later? Strings, of course, are arrays.
>
>Suppose every data structure were in its own segment...
>
>Would this be worth doing? Of course, it would complicate the OS's
>memory management duties. But think about it.

No, for four reasons:

 - It is very expensive to expand pointers to hold a reasonably large 
   (16 bit?) segment number field.

 - Other things being equal, address translation is slowed considerably 
   by segment bounds checking.

 - Non-uniform pointers lead to additional software complexity and cause 
   severe problems when porting code from traditional systems.

 - You can easily accomplish what you want to do in a pure paged
   system.  Just decide that you are going to use an arbitrary number of
   pointer bits for the "segment" number and load your page tables
   accordingly.  The only difference is that segment granularity is one
   page, but that shouldn't matter for the debugging application you
   mention.



More information about the Comp.lang.c mailing list