Chapter 7 Virtual Memory p1
Chapter 7 Virtual Memory p1
Memory
Hardware and Control Structures
Two characteristics fundamental to
memory management:
1) all memory references are logical addresses that
are
dynamically translated into physical addresses at
run time
2) a process may be broken up into a number of pieces
that don’t need to be contiguously located in main
memory during execution
If these two characteristics are present, it is not
necessary that all of the pages or segments of a
process be in main memory during execution
Operating system brings into main memory a few pieces of
the program
Resident set - portion of process that is in main memory
An interrupt is generated when an address is needed that is
not in main memory
Operating system places the
process in a blocking state
Continued . . .
Execution of a Process
To bring the piece of process that contains the logical address into
main memory
operating system issues a disk I / O Read request
another process is dispatched to run while the disk I/O takes
place
an interrupt is issued when disk I / O is complete, which
causes the operating system to place the affected process in
the Ready state
Implications
More processes may be maintained in main memory
only load in some of the pieces of each process
with so many processes in main memory, it is very likely
a
process will be in the Ready state at any particular time
A process may be larger than all of main memory
Real and Virtual Memory
Real memory
• main memory, the actual RAM
Virtual memory
• memory on disk
• allows for effective multiprogramming and relieves
the user of tight constraints of main memory
Table 8.2
Characteristics of
Paging and
Segmentation
A state in To avoid this,
which the the operating
system spends system tries to
most of its guess, based on
time swapping recent history,
process pieces which pieces are
rather than least likely to be
executing used in the near
instructions future
Principle of Locality
Program and data references within a process tend to cluster
Only a few pieces of a process will be needed over a
short period of time
Therefore it is possible to make intelligent guesses about
which pieces will be needed in the future
Avoids thrashing
For virtual memory to be practical
and effective:
• hardware must support paging
and segmentation
• operating system must include software for
managing the movement of pages and/or
segments between secondary memory
and main memory
Paging
The term virtual memory is usually associated with systems
that employ paging
Each process has its own page table
each page table entry contains the frame number of the
corresponding page in main memory
Memory
Management
Formats
Address Translation
• In most systems, there is one page table per process.
most obvious on
personal computers
where applications
are becoming
increasingly complex
Segmentation
Advantages:
Segmentation • simplifies handling
allows the of growing data
programmer to structures
view memory • allows programs
as consisting of to be altered and
multiple address recompiled
independently
spaces or
• lends itself to
segments
sharing data
among processes
• lends itself to
protection
Segmentation
Segment Organization
Each segment table entry contains the starting address of the
corresponding segment in main memory and the length of
the segment
A bit is needed to determine if the segment is already in
main
memory
Another bit is needed to determine if the segment has
been modified since it was loaded in main memory
Address Translation
Combined Paging
and
Segmentation
In a combined
paging/segmentation system
a user’s address space is Segmentation is visible to
broken up into a number of the
segments. programmer