Operating Systems: Internals and Design Principles: Memory Management
Operating Systems: Internals and Design Principles: Memory Management
Systems:
Internals
and Design
Principles Chapter 7
Memory Management
Seventh Edition
William Stallings
Operating Systems:
Internals and Design Principles
I cannot guarantee that I carry all the facts in my mind.
Intense mental concentration has a curious way of
blotting out what has passed. Each of my cases
displaces the last, and Mlle. Carère has blurred my
recollection of Baskerville Hall. Tomorrow some other
little problem may be submitted to my notice which will in
turn dispossess the fair French lady and the infamous
Upwood.
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
Disadvantages
A program may be too big to fit in a partition
program needs to be designed with the use of overlays
Fixe
d
Parti
tioni
ng
Disadvantages
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
Dynamic Partitioning
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
chooses the
●
memory from the memory from the
location of the last
block that is beginning and
placement and
closest in size chooses the first chooses the next
available block that available block that
to the request is large enough 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 2 U is the size of the
entire memory available for allocation
Buddy System Example
Tree
Repre
sentati
on
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 or Absolute
●
actual location in main memory
Relocation
Paging
Partition memory into equal fixed-size chunks that are relatively
small
Process is also divided into small fixed-size chunks of the same size
Pages Frames
●
chunks of a process available 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-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
Security Issues
If a process has not
declared a portion of its
memory to be sharable,
then no other process
should have access to the
contents of that portion of
memory
Compile-time Defenses
●
aim to harden programs to resist attacks in new programs
Run-time Defenses
●
aim to detect and abort attacks in existing programs
Memory Management
Summary
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