Segmentation in Linux

  • Segmentation encourages splitting a program into subroutines
  • Linux uses segmentation in a limited way it prefers paging which can make segmentation redundant
    • Memory management is simpler with paging
    • Paging is more adaptable to more systems (RISC arch doesn’t support segmentation)
  • 2.6 Kernel only uses segmentation when required by the x86 architecture
  • All User Mode processes share the same code and data segments
    • All Kernel Mode processes share the same kernel code and kernel data segments
    • Capture.PNG
    • These have macros __USER_CS, __USER_DS, __KERNEL_CS, __KERNEL_DS
      • To access these segments load each macro into its corresponding segmentation register
      • ss (stack segment) always contains the corresponding level stack descriptor
    • Notice that the base address starts from 0
      • This means that the 32 bit offset in the segment selector will always correspond to the linear address
      • This is fine because the MMU is responsible for linear->physical we do not need to be worried abotu conflicting address values
      • In C when you do
         int *ptr=&x;

        what you’re given is actually the linear address not the physical address.  Therefore ptrs of an array though in “linear” address space are contiguous may not be contiguous in physical

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s