Upload
myrajendra
View
997
Download
2
Tags:
Embed Size (px)
Citation preview
1
• Segmentation
Storage Management
3
Recap
In the last class, you have learnt:
• Fragmentation
• Paging concepts
4
Objective
On completion of this class, you will be able to
know
• Segmentation
5
Segmentation• Memory-management scheme that supports user
view of memory• A program is a collection of segments • A segment is a logical unit such as:
main program,
procedure,
function,
method,
object,
local variables, global variables,
common block,
stack,
symbol table, arrays, etc..
6
User’s View of a Program
Subroutine
Sqrt
Main Program
Symbol table
Stack
Logical address space
7
Logical View of Segmentation
1
3
2
4
user space
1
4
2
3
physical memory space
8
Segmentation
• Each segment has a name and length
• Address specify both the segment name and
offset
• Instead of using name the segments are
numbered
• The logical address consists of a tuple:
– <segment-number,offset>
9
Segmentation Architecture
• 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
• Use of segment table is illustrated in the next
slide
10
Segmentation Hardware (contd..)
11
• Logical address generated by CPU consists of two
parts
– Segment no. ‘s’:-used as a index into segment table
– Offset ‘d’:- must be between ‘0’ and segment limit
– A trap is generated if offset exceeds the segment limit
– Correct offset + segment base = address in physical
memory
• Segment table is an array of base-limit register pair
Segmentation Hardware
12
Paging Hardware
HARDWARE -- Must map a tuple (segment / offset) into one-dimensional address
CPU
MEMORY
+<
No
LogicalAddress Yes
PhysicalAddress
Segment Table
Limit Base
S D
13
Example of Segmentation
• Five segments numbered from 0 through 4.
• The segments are stored in physical memory as
shown in fig.1
• Segment table gives the details of limit and base
of each segment
– Ex. Segment 2 is 400 bytes long and begins at
location 4300
– A reference to 53 of segment 2 is mapped onto
location 4300+53=4353
14
Example of Segmentation
segment 0
segment 3
segment 2
segment 4
segment 1
limit base
1000
400
400
1100
1000
1400
6300
4300
3200
4700
Subroutine
Sqrt
Main Program
Symbol table
Stack
Logical address space
segment 0
segment 3
segment 4
segment 2
segment 1
1400
3200
4300
4700
5700
6300
6700
2400
Physical Memory
Figure :1
Ex: Segment 2 = 4300+53=4353
Segment table
15
Segmentation, Paging - Comparison
• Segments are variable-size; Pages are fixed-size
• Segmentation requires more complicated
hardware for address translation than paging
• Segmentation suffers from external fragmentation
• Paging only yields a small internal fragmentation
16
Summary
In this class you have learnt
• Segmentation
– Pages
– frames
17
Frequently Asked Questions
• What is segmentation?
• Explain the segmentation hardware with a neat
diagram
18
Quiz
1. Memory-management scheme that supports user view of memory
a) Segmentationb) Paging scheme C) None
2. The logical address consists of a a) Page offset b) Hole c) Tupled) None
Other subject materials
• Web designing
• Micro processors
• C++ tutorials
• java
home
20
Quiz
3. ____________used as a index into segment
table
a) Page number
b) Segment no. ‘s’
c) Compaction
d) None
21
Quiz
4. _________must be between 0 and segment
limit
a) External fragmentation
b) Offset ‘d’
c) Compaction
d) None