Memory Management

Only available on StudyMode
  • Topic: Virtual memory, Memory management, Physical address
  • Pages : 9 (2154 words )
  • Download(s) : 23
  • Published : February 11, 2013
Open Document
Text Preview
Synthesis
Memory Management
Binding of Instructions and Data to Memory
Compile time:
* known memory location
* absolute code can be generated
* must recompile code if starting location changes.
Load time:
* generate re-locatable code if memory location is not known at compile time. Execution time:
* process can be moved during its execution from one memory segment to another. * need hardware support for address mapping
Logical vs. Physical Address Space
* A logical address space that is bound to a separate physical address space – Logical address – generated by the CPU; also referred to as virtual address. – Physical address – address generated by the memory management unit. * Logical and physical addresses are the same in compile-time and load-time address binding schemes. Logical (virtual) and physical addresses differ in execution-time address-binding scheme.

Memory-Management Unit (MMU)
* Hardware device that maps logical/virtual to physical address. * In MMU the value in the relocation register is added to every address generated by a program at the time the address is sent to memory. * The program deals with logical addresses; it never sees the real physical addresses.

Contiguous Memory Allocation
* Multiple partitions for multiple processes.
* Relocation register and limit registers to protect processes from one another (and protect OS code) * Both registers are part of process context.
* Relocation register contains value of smallest physical address. * Limit register contains range of logical addresses.
* Each logical address must be less than the limit register. Multi-partition Allocation
* Holes are blocks of available memory
* Holes of various size are scattered throughout memory.
* When a process arrives, it is allocated memory from a hole large enough to accommodate it. * Operating system maintains information about:
– allocated partitions
– free partitions

Dynamic Storage Allocation Problem
* How to satisfy a request for memory 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 ordered by size. Produces the smallest leftover hole. * Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. * Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole Fragmentation

* External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous. * Internal Fragmentation – allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used. * Reduce external fragmentation by compaction

– Shuffle memory contents to place all free memory together in one large block. – Compaction is possible only if address binding is dynamic, and is done at execution time. Non-Contiguous Memory Allocation

* Goal: Reduce memory loss to external fragmentation without incurring the overhead of compaction * Solution: Abandon the requirement that allocation memory be contiguous. * Non-contiguous memory allocation approaches include:

* Paging: Allow logical address space of a process to be noncontiguous in physical memory. This complicates the binding (MMU) but allows the process to be allocated physical memory wherever it is available. * Segmentation: Allow the segmentation of a process into many logically connected components. Each begins at its own (local) virtual address 0. * This allows many other useful features, including protection permisions on a per segment basis, etc. * Example segmentation: Text, Data, Stack.

* Segmentation with Paging:...
tracking img