Professional Documents
Culture Documents
17 Memory Management
17 Memory Management
Management
Frame A fi xed- l engt h bl ock of mai n memor y.
A fi xed- l engt h bl ock of dat a t hat r esi des i n secondar y memor y
Page ( such as di sk) . A page of dat a may t empor ar i l y be copi ed i nt o a
f r ame of mai n memor y.
A var i abl e- l engt h bl ock of dat a t hat r esi des i n secondar y memor y.
An ent i r e segment may t empor ar i l y be copi ed i nt o an avai l abl e
Segment r egi on of mai n memor y ( segment at i on) or t he segment may be di vi ded
i nt o pages whi ch can be i ndi vi dual l y copi ed i nt o mai n memor y
( combi ned segment at i on and pagi ng) .
Increasing
address
values
Reference
to data
Data
Current top
of stack
Stack
Inefficient use of
Partitions are created dynamically, No internal
processor due to the
Memory
so that each process is loaded into a fragmentation; more
Dynamic Partitioning need for compaction to
partition of exactly the same size as efficient use of main
that process. memory. counter external
fragmentation.
Techniques
SimplePaging equal-size pages of the same length
as frames. A process is loaded by fragmentation. internal fragmentation.
loading all of its pages into
available, not necessarily
contiguous, frames.
No external
As with simple paging, except that
it is not necessary to load all of the fragmentation; higher
Virtual Memory degree of Overhead of complex
pages of a process. Nonresident
Paging pages that are needed are brought in multiprogramming; memory management.
later automatically. large virtual address
space.
No internal
As with simple segmentation,
fragmentation, higher
except that it is not necessary to
degree of
Virtual Memory load all of the segments of a Overhead of complex
multiprogramming;
Segmentation process. Nonresident segments that large virtual address memory management.
are needed are brought in later
space; protection and
automatically.
sharing support.
OperatingSystem OperatingSystem
8M 8M
2M
8M 4M
6M
8M
8M
8M
8M
8M
12M
8M
8M
16M
8M
New New
Processes Processes
External Fragmentation
P2
P1
(14M)
(20M)
Memory external to all processes is
fragmented
Empty (6M)
Empty
P4(8M)
P2
Can resolve using compaction
(56M)
(14M) OS moves processes so that they are
Empty (6M)
contiguous
Time consuming and wastes CPU
P3 time
(18M)
Empty (4M)
Traditional UNIX Systems
Were developed at Bell Labs and became operational on a PDP-7 in
1970
36M
Process 3 18M
22M
4M
Process 2 14M
Process 1 20M Process 1 20M 20M
6M
Process 4 8M Process 4 8M Process 4 8M
14M
6M 6M 6M
4M 4M 4M 4M
12M 12M
First Fit
22M
6M
Best Fit
Last 18M
allocated 2M
block (14M)
8M 8M
6M 6M
Allocated block
Free block
Next Fit
36M
20 M
ReleaseD 1M
Adder Program
Absolute
address
Data
Interrupt to
operatingsystem
Stack
Process imagein
main memory
(a) Fifteen Available Frames (b) Load Process A (c) Load Process B
0000010111011110
0001100111011110
16-bit physical address
(a) Paging
16-bit
0010001 1 0 0 phys
0 1 0ical
0 0 addre
0 ss
(a) Paging 16-bit physical address
(b) Segmentation
Figical
16-bit log ure7.12 Exam
addre ssplesof Logical-to-Physical AddressTranslation
4-bit segment #
Segmentation
A program can be subdivided into
segments
may vary in length
there is a maximum length
Addressing consists of two parts:
segment number
an offset
Similar to dynamic partitioning
Eliminates internal fragmentation
Segmentation
Usually visible
Provided as a convenience for organizing
programs and data
Typically the programmer will assign programs
and data to different segments
For purposes of modular programming the
program or data may be further broken down
into multiple segments
the principal inconvenience of this service is that the
programmer must be aware of the maximum segment
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
USER’S VIEW OF A PROGRAM
LOGICAL VIEW OF
SEGMENTATION
1
4
1
3 2
4
A. Frank - P. Weisberg