0% found this document useful (0 votes)
44 views

Chapter 6 Memory Management

Memory management aims to satisfy requirements of relocation, protection, sharing, logical and physical organization. It uses techniques like segmentation, paging, and dynamic partitioning to allocate memory to processes efficiently while allowing processes to be moved in and out of memory. The goal is to maintain as many active processes as possible in main memory and free programmers from strict size limitations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Chapter 6 Memory Management

Memory management aims to satisfy requirements of relocation, protection, sharing, logical and physical organization. It uses techniques like segmentation, paging, and dynamic partitioning to allocate memory to processes efficiently while allowing processes to be moved in and out of memory. The goal is to maintain as many active processes as possible in main memory and free programmers from strict size limitations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Memory

Management
Memory
Management
Terms
Memory Management
Requirements
 Memory management is intended to satisfy
the following requirements:
 Relocation
 Protection
 Sharing
 Logical organization
 Physical organization
Relocation
 Programmers typically do not know in advance which other
programs will be resident in main memory at the time of execution
of their program
 Active processes need to be able to be swapped in and out of
main memory in order to maximize processor utilization
 Specifying that a process must be placed in the same
memory region when it is swapped back in would be
limiting
 may need to relocate the process to a different
area of memory
Addressing Requirements
Protection
 Processes need to acquire permission to reference memory locations
for reading or writing purposes
 Location of a program in main memory is unpredictable
 Memory references generated by a process must be checked at run
time
 Mechanisms that support relocation also support protection
Sharing
 Advantageous to allow each process access to the same copy
of the program rather than have their own separate copy
 Memory management must allow controlled access to
shared areas of memory without compromising protection
 Mechanisms used to support relocation support sharing
capabilities
Logical Organization
 Memory is organized as linear

 Segmentation is the tool that most readily


satisfies
requirements
Physical Organization

Cannot leave the


Memory available for a Programmer does not
programmer with the
program plus its data know how much space
responsibility to manage
may be insufficient will be available
memory

overlaying allows various


modules to be assigned
the same region of
memory but is time
consuming to program
Memory Partitioning
 Memory management brings processes into main memory
for execution by the processor
 involves virtual memory
 based on segmentation and paging
 Partitioning
 used in several variations in some now-obsolete
operating systems
 does not involve virtual memory
Table 7.2
Memory
Management
Techniques
Fixed Partitioning
 Equal-size partitions
 any process whose size is less than
or equal to the partition size can
be loaded into an available
partition
 The operating system can swap
out a process if all partitions
are full and no process is in the
Ready or Running state
 A program may be too big to fit in a partition
 program needs to be designed with the use of
overlays
 Main memory utilization is inefficient
 any program, regardless of size, occupies an
entire partition
 internal fragmentation

 wasted space due to the block of data loaded


being smaller than the partition
Unequal Size Partitions
 Using unequal size partitions helps lessen
the problems
 programs up to 16M can be
accommodated without overlays
 partitions smaller than 8M allow
smaller programs to be accommodated
with less internal fragmentation
Memory Assignment
P n
a i
r n
F
t g
i
i
x
t
e
i
d
o
 The 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
 Partitions are of variable length and number
 Process is allocated exactly as much memory as
it requires
 This technique was used by IBM’s
mainframe operating system, OS/MVT
Effect
of
Dynamic
Partitioning
Dynamic Partitioning

External Fragmentation
• memory becomes more and more fragmented
• memory utilization declines

Compaction
• technique for overcoming external
fragmentation
• OS shifts processes so that they are contiguous
• free memory is together in one block
• time consuming and wastes CPU time
Placement Algorithms

Best-fit First-fit Next-fit


• chooses the • begins to • begins to
block that is scan memory scan memory
closest in from the from the
size to the beginning location of
request and chooses the last
the first placement
available and chooses
block that is the next
large enough available
block that is
large enough
Memory
Configuration
Example
Buddy System
 Comprised of fixed and dynamic
partitioning schemes
 Space available for allocation is treated as
a single block
 Memory blocks are available of size 2K
words, L ≤ K ≤ U, where
 2L = smallest size block that is allocated
 2U = largest size block that is allocated; generally 2U is the size of the
entire memory available for allocation
Buddy System Example
T R n
r e t
e p a
e r t
e i
s
o en
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 (a particular example of logical address)
Physical or Absolute
• actual location in main
memory
 Partition memory into equal fixed-size chunks (termed frames)
that are relatively small
 Process is also divided into small fixed-size chunks (termed
pages)
of the same size
Pages Frames
• chunks of a • available
process chunks of
memory
Assignment of
Process to
Free Frames
Page Table
 Maintained by operating system for each process
 Contains the frame location for each page in the process
 Processor must know how to access for the current
process
 Used by processor to produce a physical address
Data Structures
Logical Addresses
Logical address
= page # + offset within page

16-bit address

Page size = 1KB


= 210 Bytes
Logical-to-Physical Address
Translation - Paging
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
Logical-to-Physical Address
Translation - Segmentation
 Memory
Summary
Management
 one of the most important and complex tasks of
an operating system
 needs to be treated as a resource to be allocated to
and shared among a number of active processes
 desirable to maintain as many processes in
main memory as possible
 desirable to free programmers from size restriction
in program development
 basic tools are paging and segmentation (possible
to combine)
 paging – small fixed-sized pages
 segmentation – pieces of varying size

You might also like