Sei sulla pagina 1di 5

Chapter 7: Memory

Management
1. Requirement for Memory Management
a. Relocation
- Active processes need to
be able to be swapped in
and out of main memory
in order to maximize
processor utilization
- Relocate process to a
different area of memory
b. Protection
- Processes need to acquire permission to reference
memory location for reading/writing purposes
- Location of program in main memory is unpredictable
- Memory references generated by a process must be
checked at run time
c. Sharing
- To allow each process access to the same copy of the
program rather than have their separate copy
- Must allow controlled access to shared areas of memory
without compromising protection
d. Logical organization
- Programs are written in modules
Modules can be written & compiled independently
Different degrees of protection given to modules
(read-only, execute-only)
Sharing on a module level corresponds to the users
way of viewing the problem
- Segmentation = tool that most readily satisfies
requirements.
e. Physical organization

2. Memory Partitioning
a. Brings processes into main memory for execution by the
processor
- Involves virtual memory
- Based on segmentation & paging
b. Partitioning
- Used in several variations in some now-obsolete OS
- Does not involve virtual memory
I. Fixed-partitioning
Disadvantages
Program too big to fit a partition
Program needs to be designed with the
use of overlays
Main memory utilization is inefficient
Any program, regardless of size, occupies
entire partition
Internal fragmentation
Wasted space due to the block of data
loaded being smaller than the partition
Number of partitions specified at system generation
time limits the number of active processes in the
system
Small jobs will not utilize partition space efficiently
II. Dynamic Partitioning
Partition are of variable length and number
Process is allocated exactly as much as acquire
External Fragmentation
Memory becomes more & more
fragmented
Memory utilization declines
Compaction
Technique for overcoming external
fragmentation
OS shift processes so they are
contiguous
Free memory is together in one block
Time consuming & wastes CPU time
Placement Algorithms
Best-fit
Chooses the block that is closest in
size to request
First-fit
Begins to scan memory from the
beginning & chooses the first
available block that is large
enough

Next-fit
Begins to scan memory from the
location of the last placement &
chooses the next available block
that is large enough
III. Buddy Systems
comprised of
fixed & dynamic
partitioning
schemes
space available
for allocation is
treated as a
single block
Memory blocks
are available of
size 2K words
o 2L =
smallest
size block
o 2U =
largest size block
c. Addresses

- Logical
Reference to a memory location independent of the
-

current assignment of data to memory


Relative
Address is expressed as a location relative to some
known point
Physical/Absolute
Actual location in main memory

d. Paging
- Partition memory into equal fixed-size chunks that are relatively
small
- Process divided into small fixed-size chunks of same size
Pages
Frames
- Chunks of a process
- Available chunks of memory
- Page Table
o Maintained by OS for each process
o Contains the frame location for each page in the process
o Processor must know how to access for the current process
o Used by processor to produce physical address
e. Segmentation

Program can subdivided into segments


o May vary in length
o Have max length
- Addressing consist 2 parts
o Segments number
o An offset
- Similar to dynamic partitioning
- Eliminates internal fragmentation
- Usually visible & provide as a convenience for organizing programs
& data
- The programmers will assign programs & data to different segments
- May be further broken down into multiple segments for modular
programming
f. Address Translation
- Steps:
o Extract the segment number as the leftmost n bits of the
logical address.
o Use the segment number as an index into the process
segment table to find the starting physical address of the
segment.
o Compare the offset, expressed in the rightmost n bits, to the
length of the segment. If the offset is greater than or equal o
the length, the address is invalid.
o The desired physical address is the sum of the starting
physical address of the segment plus the offset.

Chapter 8: Virtual Memory


1. Definition
a. Virtual memory = storage allocation scheme in which
secondary memory can be addressed as though it were part of
main memory.
b. Virtual address = the address assigned to the location in
virtual memory to allow that location to be accessed as
thought it were part of main memory.
c. Virtual address space = the virtual storage assigned to a
process.
d. Address space = range of memory address available to a
process.
e. Real address = address of a storage location in main
memory.
2. Hardware & Control Structures
- 2 characteristics fundamental to memory management
o all memory references are logical addresses that are
dynamically translated into physical addresses at run time.

o A process may be broken up into a number of pieces that


dont need to be contiguously located in main memory during
execution.
Execution of a Process
o OS brings to main memory a few pieces of the program
o

Potrebbero piacerti anche