Figure 1:
Logical View of Segmentation (left) , User's View of a Program (right).
|
- The most important problem with base-and-limits (see Fig. ) relocation is that there is only one segment for each process
- Segmentation generalizes the base-and-limits technique by allowing each process to be split over several segments (i.e., multiple base-limits pairs)
- Segment table maps 2-dimensional physical addresses (segment-number, offset); each table entry has:
- base; contains starting physical address where segments reside in memory
- limit specifies length of segment
- Table entries are filled as new segments are allocated for the process
- A segment is a region of contiguous memory. Although the segments may be scattered in memory, each segment is mapped to a contiguous region
- Memory-management scheme that supports user view of memory (see Fig. 1)
- Program is collection of segments. Segment a logical unit such as:
main program, procedure, function, method, object, local variables, global variables, common block, stack, symbol table, array (see Fig. 2)
Figure 2:
Example of Segmentation
|
- When a process is created, an empty segment table is inserted into the process control block (PCB)
- The segments are returned to the free segment pool when the process terminates
- Segmentation, as well as the base and limits approach, causes external fragmentation (because they require contiguous physical memory) and requires memory compaction
- An advantage of the approach is that only a segment, instead of a whole process, may be swapped to make room for the (new) process.
- Like paging, use virtual addresses and use disk to make memory look bigger that it really is
- Segmentation can be implemented with or without paging
- Segment-table base register (STBR) points to segment table's location in memory
- Segment-table length register (STLR) indicates number of segments used by a program , segment number s is legal if s STLR
- Segmentation Architecture
- Relocation; dynamic, by segment table
- Sharing; shared segments, same segment number
- Allocation; first fit/best fit, external fragmentation
- Protection: with each entry in segment table: illegal segment, read/write/execute privileges
- Protection bits associated with segments; code sharing at segment level
- Since segments vary in length, memory allocation a dynamic storage-allocation problem
Figure 3:
Sharing of Segmentation
|
Subsections
2004-05-02