Operating Systems: Simple/Basic Segmentation
Operating Systems: Simple/Basic Segmentation
Simple/Basic
Segmentation
A. Frank - P. Weisberg
Real Memory Management
• Background
• Memory Management Requirements
• Fixed/Static Partitioning
• Variable/Dynamic Partitioning
• Simple/Basic Paging
• Simple/Basic Segmentation
• Segmentation with Paging
2 A. Frank - P. Weisberg
Simple/Basic Segmentation
• Paging division is arbitrary; no natural/logical
boundaries for protection/sharing.
• Segmentation supports user’s view of a
program.
• A program is a collection of segments –
logical units – such as:
main program, subprogram, class
procedure, function,
object, method,
local variables, global variables,
common block,
stack, symbolA.table, arrays
3 Frank - P. Weisberg
User’s View of a Program
4 A. Frank - P. Weisberg
Example of Segmentation Need
8 A. Frank - P. Weisberg
Logical view of simple segmentation
4
1
3 2
4
9 A. Frank - P. Weisberg
Dynamics of Simple Segmentation (2)
• In contrast with paging, segmentation is visible
to the programmer:
– provided as a convenience to organize logically
programs (example: data in one segment, code in
another segment).
– must be aware of segment size limit.
• The OS maintains a segment table for each
process. Each entry contains:
– the starting physical addresses of that segment.
– the length of that segment (for protection).
10 A. Frank - P. Weisberg
Example of Segmentation
11 A. Frank - P. Weisberg
Logical address in segmentation
12 A. Frank - P. Weisberg
Logical address used in segmentation
• When a process enters the Running state, a dedicated
register gets loaded with the starting address of the
process’s segment table.
• Presented with a logical address (segment number,
offset) = (s, d), the CPU indexes (with s) the segment
table to obtain the starting physical address b and the
length l of that segment.
• The physical address is obtained by adding d to b (in
contrast with paging):
– the hardware also compares the offset d with the length l of
that segment to determine if the address is valid.
13 A. Frank - P. Weisberg
Logical-to-Physical Address Translation in segmentation
14 A. Frank - P. Weisberg
Segmentation Architecture
• Logical address consists of a two tuple:
<segment-number, offset>,
• Segment table – maps two-dimensional physical addresses;
each table entry has:
– base – contains the starting physical address where the
segments reside in memory.
– limit – specifies the length of the segment.
• Segment-table base register (STBR) points to the 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.
15 A. Frank - P. Weisberg
Address Translation Architecture
16 A. Frank - P. Weisberg
Protection in Segmentation
• Protection – with each entry in segment table
associate:
– validation bit = 0 illegal segment
– read/write/execute privileges
• Protection bits associated with segments;
code sharing occurs at segment level.
• Since segments vary in length, memory
allocation is a dynamic storage-allocation
problem.
17 A. Frank - P. Weisberg
Sharing in Segmentation Systems
18 A. Frank - P. Weisberg
Shared Segments Example
19
Simple segmentation/paging comparison (1)
20 A. Frank - P. Weisberg
21 A. Frank - P. Weisberg
Simple segmentation/paging comparison (2)
23 A. Frank - P. Weisberg
MULTICS Address Translation Scheme
24 A. Frank - P. Weisberg
Example: The Intel Pentium
26 A. Frank - P. Weisberg
Intel Pentium Segmentation
27 A. Frank - P. Weisberg
Pentium Paging Architecture
28 A. Frank - P. Weisberg
Three-level Paging in Linux
29 A. Frank - P. Weisberg