Docsity

Memory Management: Swapping, Allocation, Paging, Segmentation, and Virtual Memory, Slides of Operating Systems

Partial preview of the text

Download Memory Management: Swapping, Allocation, Paging, Segmentation, and Virtual Memory and more Slides Operating Systems in PDF only on Docsity!

MEMORY MANAGEMENT

Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

Background

  • Program must be brought into memory and placed within a process for it to be run.
  • Input queue – collection of processes on the disk that are waiting to be brought into memory to run the program.
  • User programs go through several steps before being run.

Multistep

Processing of a

User Program

Logical vs. Physical Address Space

  • logical address space is bound to a separate physical address space. - Logical address – generated by the CPU; also referred to as virtual address. - Physical address – address seen by the memory 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.

Dynamic relocation using a relocation

register

Dynamic Loading

  • Routine is not loaded until it is called
  • Better memory-space utilization; unused routine is never loaded.
  • Useful when large amounts of code are needed to handle infrequently occurring cases.
  • No special support from the operating system is required  implemented through program design.

Overlays

  • Keep in memory only those instructions and data that are needed at any given time.
  • Needed when process is larger than amount of memory allocated to it.
  • Implemented by user, no special support needed from operating system, programming design of overlay structure is complex

Overlays for a Two-Pass Assembler

Swapping

  • Roll out, roll in – swapping variant used for priority-based scheduling algorithms; lower- priority process is swapped out so higher-priority process can be loaded and executed.
  • Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped.
  • Modified versions of swapping are found on many systems, i.e., UNIX, Linux, and Windows.Docsity.com

Schematic View of Swapping

Hardware Support for Relocation and

Limit Registers

Contiguous Allocation (Cont.)

  • Multiple-partition allocation
    • Hole – block 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: a) allocated partitions b) free partitions (hole)

OS process 5 process 8 process 2

OS process 5

process 2

OS process 5

process 2

OS process 5 process 9

process 2

process 9 process 10

Buddy System

  • uses the way numbers are stored - in binary.
    • memory is only allocated in units that are powers of
  • If 3 bytes are requested you get 4
  • if 129 bytes are requested you get 256.
  • leads to wasted space (internal fragmentation).

Buddy System