Segmentation

Lists of Descriptive Questions Answers and Short Study Notes On Operating System – Segmentation

  • (1) what is Segmentation? Explain.

 

Question-1 what is Segmentation? Explain.

  • Virtual memory is one-dimensional in nature because the virtual address space go from 0 to some maximum address, one address after another.
  • There are many problems where separate virtual address space for different entities of process is much better Segment
  • A general solution is to provide the machine with many independent address spaces called segments.
  • Each segment consists of a linear sequence of addresses, from 0 to the maximum allowed.
  • Different Segments may have different lengths.
  • Segment lengths may change during execution.
  • Different Segments can grow or shrink independently without affecting each other.
  • To specify address in these segments or two dimensional memories, the program must supply a two part address, a segment number and address within the segment.

 

Advantages of Segmentation

  • Segmentation provides simplified data structure to handle growing and shrinking of data.
  • If each procedure occupies a separate segment, with address 0 as its starting address, the linking of procedures compiled separately is simplified.
  • If the procedure in segment n is modified and recompiled, no other procedures need to be changed.
  • Segmentation also facilitates sharing procedures or data between several processes. A common example is shared library.
  • Each segment forms a logical entity of which the programmer is aware, such as procedure, or an array, or a stack, different segments can have different kind of protection.
  • In paging system programmer is unaware of the content of pages, but in segmentation user knows in advance the content of the segments.

 

Paged Segmentation

  • Generally in segmented memory swapping done entirely in segment wise. Entire segment get swapped-out or swapped-in.
  • If segments are large, it may be inconvenient or even impossible to keep them in main memory in their entirely.
  • Idea of paging the segments is practical one, so only those pages from segments that are actually needed have to be around, these concept dividing segments into pages is called paged segmentation.

 

Figure 5-12. A segmented memory allows each table to grow or shrink independently

 

  • Here, an example of MULTICS is considered to understand segmentation with paging.
  • Segmented memory Virtual Address consists of two parts: the segment number and address within segment, the address within segment is further divided into a page number and a word within a page.
  • Program has a segment table, with one entry per segment, its entry contains pointer to its page table.

 

When memory reference occurs, the following steps occur

o The segment number used to find segment descriptor.

o Check is made to see if the segment’s page table is in memory.

  • If not, segment fault occurs.
  • If there is a protection violation, a fault (trap) occurs.

o Page table entry for the requested virtual page examined.

If the page itself is not in memory, a page fault is triggered.

If it is in memory, the main memory address of the start of the page  is extracted from the page table entry

o The offset is added to the page origin to give the main memory address where the word is located.

o The read or store finally takes place.

 

Figure 5-13. A 34-bit MULTICS virtual address.

 

Figure 5-14 (a). The MULTICS virtual memory. The descriptor segment points to the Page tables.

 

Figure 5-14. The MULTICS virtual memory. (b) A segment descriptor. The numbers are the field lengths.