- 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:
- A page number
- An offset
- 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 |
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:
- Next instruction to execute
- Next data that needs to be accessed
To do:
- Load part of the program
- Keep reading from RAM until cannot find next page in RAM (page fault)
- Block the process, read in data, resume
-
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
- 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
- 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)