Chapter 9: Memory Management - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Chapter 9: Memory Management

Description:

Logical and physical addresses differ in execution-time address-binding scheme. ... How to satisfy a request of size n from a list of free holes? ... – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 9
Provided by: marily214
Category:

less

Transcript and Presenter's Notes

Title: Chapter 9: Memory Management


1
Chapter 9 Memory Management
  • Background
  • Contiguous Memory Allocation
  • Paging

2
Binding of Instructions and Data to Memory
Binding of instructions and data to memory
addresses canhappen at three different stages
  • Compile time If memory location of process is
    known a priori, absolute code can be generated.
  • Must recompile code if starting location changes
  • Load time if memory location of process is not
    known at compile time, compiler must generate
    relocatable code.
  • Must reload code if starting location changes
  • Execution time if the process can be moved from
    one memory segment to another during its
    execution, binding must be delayed until run
    time.
  • Need special hardware support
  • Use by most modern OS

3
Logical- vs. Physical-Address Space
  • Logical address address generated by the CPU.
  • Physical address address seen by the memory
    unit.
  • Logical-address space the set of all logical
    addresses generated by a program.
  • Physical-address space the set of all physical
    addresses corresponding to the logical addresses
  • Logical and physical addresses are the same in
    compile-time and load-time address-binding
    schemes
  • Logical and physical addresses differ in
    execution-time address-binding scheme.
  • Memory Management Unit (MMU) hardware device
    that performs run-time mapping from logical to
    physical addresses.

4
Contiguous Memory Allocation
  • A process physical memory is contiguous
  • Memory protection
  • limit register contains the range of logical
    addresses each logical address must be less
    than the limit register.
  • Logical addresses in range 0..limit-1
  • MMU maps logical address to physical address by
    adding the value in the relocation register to
    the logical address
  • relocation register contains the value of the
    smallest physical address
  • Physical addresses in range relocation..relocatio
    nlimit-1
  • During context switch, dispatcher loads
    relocation/limit registers from PCB

5
Hardware Support for Relocation and Limit
Registers
6
Memory Allocation
  • Hole a block of available memory
  • When a process arrives, it is allocated memory
    from a hole large enough to accommodate it
  • Allocate only as much memory as is needed
  • When a process terminates, its block of memory is
    returned to the set of holes
  • Merge adjacent holes when possible

OS
OS
OS
OS
OS
process 5
process 5
process 5
process 5
process 10
process 10
process 6
process 6
process 8
process 8
process 8
process 8
process 8
process 2
7
Dynamic Storage-Allocation Problem
  • How to satisfy a request of size n from a list of
    free holes?
  • First-fit Allocate the first hole that is big
    enough.
  • Best-fit Allocate the smallest hole that is big
    enough
  • Must search entire list, unless list is ordered
    by size.
  • Produces the smallest leftover hole.
  • Worst-fit Allocate the largest hole
  • Must also search entire list, unless list is
    ordered by size.
  • Produces the largest leftover hole.
  • Comparisons
  • First-fit usually fastest
  • First-fit and best-fit better than worst-fit in
    terms of memory utilization

8
Fragmentation
  • External Fragmentation enough total memory
    space exists to satisfy a request, but it is not
    contiguous.
  • First-fit 1/3 of memory may be unusable
  • Internal Fragmentation allocated memory may be
    slightly larger than requested memory.
  • Solutions to external fragmentation
  • Compaction shuffle memory contents to place all
    free memory together in one large block.
  • Possible only with execution-time address binding
  • Paging allow the physical-address space of a
    process to be noncontiguous
Write a Comment
User Comments (0)
About PowerShow.com