Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Engr. Abdul-Rahman MahmoodMS, PMP, MCP, QMR(ISO9001:2000)
[email protected] [email protected]
alphapeeler.sf.net/pubkeys/pkey.htm http://alphapeeler.sourceforge.net
pk.linkedin.com/in/armahmood http://alphapeeler.tumblr.com
www.twitter.com/alphapeeler [email protected]
www.facebook.com/alphapeeler [email protected]
abdulmahmood-sss alphasecure mahmood_cubix 48660186
[email protected] [email protected]
http://alphapeeler.sf.net/me http://alphapeeler.sf.net/acms/
VC++, VB, ASP
Operating Systems
Memory Management
Memory Management Terms:
Frame
Page
Segment
Memory management Requirements:
Relocation
Protection
Sharing
Logical organization
Physical organization
A fixed-length block of main memory.
A fixed-length block of data that resides in secondary memory
A variable-length block of data that resides in secondary memory.
Addressing Requirements
• Branch instructions contain an address to reference the instruction to be
executed next.
• The process stack contains a list of all threads currently running.
Logical Organization Memory is organized as linear, 1D array (bytes/words
sequence)
Segmentation satisfies logical organization requirements.
Programs are written in modules
• modules can be written and compiled independently
• different degrees of protection given to modules (read-only, execute-only)
• sharing on a module level corresponds to the user’s way of viewing the problem
Physical Organization
overlaying allows various modules to be assigned
the same region of memory but is time
consuming to program
Cannot leave the programmer with the
responsibility of memory flow from main to
secondary for 2 reasons
(1) Memory available for a program plus its data
may be insufficient
(2) Programmer does not know how much space
will be available
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
Memory Management TechniquesTechnique Description Strengths Weaknesses
Fixed
Partitioning
MM is divided into static partitions at
system generation time.
Simple to implement;
little OS overhead.
Waste of MM due
to internal
fragmentation
Dynamic
Partitioning
Partitions created dynamically, process
loads in MM partition of same size.
No internal
fragmentation; Efficient
use of MM.
Load on processor
due to compaction
to remove external
fragmentation.
Simple Paging
MM is divided in equal-size frames.
Process is divided in equal-size pages
of frame length. A process is loaded
by loading all of pages into memory frames.
No external
fragmentation.
A small amount of
internal
fragmentation.
Simple
Segmentation
Process divided in segments. Process is
loaded by loading all of its segments
into dynamic partitions.
No internal
fragmentation; improved
MM utilization
compared to dynamic
partitioning.
External
fragmentation.
Virtual
Memory
Paging
Similar to simple paging, but may not
load all process pages. Nonresident
pages may be brought in later from SS.
No ext frag.; higher
degree of
multiprogramming; large
virtual address space.
Overhead of
complex memory
management.
Virtual
Memory
Segmentation
Similar to simple segmentation, but
may not load all process segments.
Nonresident segments may be brought
in later from SS.
No ext frag.;
multiprogramming; large
virtual address space.
protection & sharing
support.
Overhead of
complex memory
management.
Fixed vs Dynamic Partitioning
Memory Assignment for Fixed Partitioning
F
i
x
e
d
P
a
r
t
i
t
i
o
n
i
n
g
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
• memory becomes more and more fragmented
• memory utilization declines
External Fragmentation
• 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
Compaction
Placement Algorithms
Best-fit
• chooses the block that is closest in size to the request
First-fit
• begins to scan memory from the beginning and chooses the first available block that is large enough
Next-fit
• begins to scan memory from the location of the last placement and chooses the next 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
e
e
R
e
p
r
e
s
e
n
t
a
t
i
o
n
Addresses
• reference to a memory location independent of the current assignment of data to memory
Logical
• address is expressed as a location relative to some known point (a particular example of logical address)
Relative
• actual location in main memory
Physical or Absolute
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
• chunks of a process
Frames
• 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 address
= page #
+ offset within page
16-bit address
Page size = 1KB
= 210 Bytes
Logical-to-Physical Address
Translation - Paging