Memory Management - PowerPoint PPT Presentation

About This Presentation
Title:

Memory Management

Description:

Information can be loaded statically or dynamically. Static Memory Allocation. Operating ... Special case of dynamic memory allocation. Suppose there is high ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 22
Provided by: garyj7
Category:

less

Transcript and Presenter's Notes

Title: Memory Management


1
Memory Management
2
Memory Manager
  • Requirements
  • Minimize executable memory access time
  • Maximize executable memory size
  • Executable memory must be cost-effective
  • Todays memory manager
  • Allocates primary memory to processes
  • Maps process address space to primary memory
  • Minimizes access time using cost-effective memory
    configuration
  • May use static or dynamic techniques

3
Address Space vs Primary Memory
Hardware Primary Memory
Process Address Space
Mapped to object other than memory
4
Building the Address Space
Source code
C
Reloc Object code
  • Compile time Translate elements

5
Primary Secondary Memory
CPU
  • CPU can load/store
  • Ctl Unit executes code from this memory
  • Transient storage

Primary Memory (Executable Memory) e.g. RAM
Secondary Memory e.g. Disk or Tape
  • Access using I/O operations
  • Persistent storage

Information can be loaded statically or
dynamically
6
Static Memory Allocation
Operating System
Unused
In Use
Process 3
Process 0
pi
Process 2
Issue Need a mechanism/policy for loading pis
address space into primary memory
Process 1
7
Fixed-Partition Memory Mechanism
Operating System
pi needs ni units
Region 0
N0
pi
ni
Region 1
N1
N2
Region 2
Region 3
N3
8
Fixed-Partition Memory -- Best-Fit
Operating System
  • Loader must adjust every address in the absolute
    module when placed in memory

Region 0
N0
Region 1
N1
Internal Fragmentation
pi
N2
Region 2
Region 3
N3
9
Fixed-Partition Memory -- Worst-Fit
Operating System
pi
Region 0
N0
Region 1
N1
N2
Region 2
Region 3
N3
10
Fixed-Partition Memory -- First-Fit
Operating System
pi
Region 0
N0
Region 1
N1
N2
Region 2
Region 3
N3
11
Fixed-Partition Memory -- Next-Fit
Operating System
Region 0
N0
pi
Region 1
N1
Pi1
N2
Region 2
Region 3
N3
12
Variable Partition Memory Mechanism
Operating System
13
Cost of Moving Programs
load R1, 0x02010
3F013010
Program loaded at 0x01000
Consider dynamic techniques
14
Dynamic Memory Allocation
  • Could use dynamically allocated memory
  • Process wants to change the size of its address
    space
  • Smaller ? Creates an external fragment
  • Larger ? May have to move/relocate the program
  • Allocate holes in memory according to
  • Best- /Worst- / First- /Next-fit

15
Special Case Swapping
  • Special case of dynamic memory allocation
  • Suppose there is high demand for executable
    memory
  • Equitable policy might be to time-multiplex
    processes into the memory (also space-mux)
  • Means that process can have its address space
    unloaded when it still needs memory
  • Usually only happens when it is blocked

16
Dynamic Address Relocation
CPU
Relative Address
0x02010
0x12010
Relocation Register
0x10000
load R1, 0x02010
MAR
  • Program loaded at 0x10000 ? Relocation Register
    0x10000
  • Program loaded at 0x04000 ? Relocation Register
    0x04000

We never have to change the load module addresses!
17
Runtime Bound Checking
CPU
Relative Address
Relocation Register
lt
Limit Register
  • Bound checking is inexpensive to add
  • Provides excellent memory protection

MAR
Interrupt
18
Memory Hierarchies Dynamic Loading
CPU Registers
Primary (Executable)
L1 Cache Memory
L2 Cache Memory
Main Memory
Larger storage
Rotating Magnetic Memory
Faster access
Optical Memory
Secondary
Sequentially Accessed Memory
19
Exploiting the Hierarchy
  • Upward moves are (usually) copy operations
  • Require allocation in upper memory
  • Image exists in both higher lower memories
  • Updates are first applied to upper memory
  • Downward move is (usually) destructive
  • Destroy image in upper memory
  • Update image in lower memory
  • Place frequently-used info high,
    infrequently-used info low in the hierarchy
  • Reconfigure as process changes phases

20
Memory Mgmt Strategies
  • Fixed-Partition used only in batch systems
  • Variable-Partition used everywhere (except in
    virtual memory)
  • Swapping systems
  • Popularized in timesharing
  • Relies on dynamic address relocation
  • Now dated
  • Dynamic Loading (Virtual Memory)
  • Exploit the memory hierarchy
  • Paging -- mainstream in contemporary systems
  • Segmentation -- the future

21
NT Memory-mapped Files
Secondary memory
Ordinary file
  • Open the file
  • Create a section object (that maps file)
  • Identify point in address space to place the file

Executable memory
Memory mapped files
Section object
Write a Comment
User Comments (0)
About PowerShow.com