Skip to content

Latest commit

 

History

History
79 lines (60 loc) · 2.78 KB

feb15-18.md

File metadata and controls

79 lines (60 loc) · 2.78 KB

Feb 15 2018

Paging:

  • Partition memory into small equal fixed sized chunks
  • Chunks of process = page
  • Chunks of memory = frame

Maintain a page table for every process, managed by OS

Memory address consists of:

  1. A page number
  2. An offset

Segmentation

  • Program is divided into segments
  • All segments of programs can be different lengths
  • Addressing consists of two parts
    • Segment number
    • Offset
  • Segments are not always equal, so similar to dynamic partitioning (unlike paging)

Can run out of segments and still have memory available

Method Description Pros Cons
Fixed Partitioning Divide memory into fixed size paritions Easy to implement Inefficient use of memory from external fragmentation
Dynamic Partitioning Partitions are created so each process is loaded into a partition of process size Efficient use of memory, no internal fragmentation Uses a lot of CPU resources for compaction
Simple Paging Main memory is divided into equal-sized frames. Processes are split into pages, load all pages into available frames No external fragmentation Some internal fragmentation
Simple Segmentation Process is split into segments, load segments into dynamic partitions No internal fragmentation, less overhead and better memory utilization than dynamic partitioning External Fragmentation

Virtual Memory:

Load the program's code and data on demand

  • Read, load from disk
  • If memory is unused, write to disk

A program can be run without being fully run in memory

Need to know:

  1. Next instruction to execute
  2. Next data that needs to be accessed

To do:

  1. Load part of the program
  2. Keep reading from RAM until cannot find next page in RAM (page fault)
  3. Block the process, read in data, resume

Performance vs Real Memory

  • lazy loading helps performance

  • but disks load batches of data faster

  • However, allows more processes to be run at once, and a process can exceed RAM size (+ functionality)

  • Real memory backed by RAM, Virtual memory by RAM and swap space

Thrashing

  • Need to compute what you want to throw out
  • Principle of Locality
    • Stuff you need in the future is close to stuff you needed in the past

Address Translation

  • Using Page tables
    • Use virtual address to check page in page table
    • Need to keep page table in RAM -> inefficient ![](/assets/Screen Shot 2018-03-14 at 2.27.59 PM.png)

  • 2 Level Hierarchical Page Table
    • Put page tables in virtual memory
    • Tells you where the page tables are stored in memory
    • More efficient
    • Cons:
      • Page table size is proportional to virtual address spae
      • Can run into 2 page faults at once

![](/assets/Screen Shot 2018-03-14 at 2.30.22 PM.png)