Lecture 10 - Memory management Flashcards
Why is memory management needed?
Memory is a resource
Processes need protection
Helps progamming if all memory looks the same
What is the memory hierarchy?
Smaller memory = faster = more volatile = more expensive
Larger memory = slower = less volatile = cheaper
What is the difference between logical and physical addresses?
Logical address - virtual address - local to the process, translated by the MMU (memory management unit)
Physical address - what the actual hardware sees
In days of job-at-a-time batch programming, how was virtual memory mapped to physical memory?
Entire physical memory was for the one job, if it didn’t fit program would manually load the next part into memory
Embedded systems use
a) virtual memory
b) physical memory
and hence there may be at most ___________ program(s) running at a time
b) physical
one
What is swapping?>
Saving a programs entire state including memory image onto a disk
Loading another program into memory
What two things does multiprogramming need from memory? Why?
Relocation - mem wont always be in same place so cant use absolute memory locations
Protection - multiple programs must not be able to access other programs memory
What is contiguous memory allocation?
Memory is partitioned into many spaces
When a process wants to run it requests a certain amount of memory
if its available OS allocates it to the process
otherwise process has to wait
What are base and limit registers?
Base register - defines the lowest address (start address) of the memory space of a program
Limit register - defines the size of the memory allocated a process
How does the memory management unit map logical addresses?
Takes offset and compares to limit register. If > limit register, raise protection fault, else add to base register - resulting address is physical memory address
What is segmentation?
A program is a collection of segments
Each segment could be allocated somewhere different in physical memory
Need a segment table with base/limit per segment to map logical to physical addresses
What are the pros and cons of segmentation?
Pros: segments are logical to us and facilitate sharing and reuse
protection can be set per segment
Cons: variable sized partitions need tricky dynamic allocation
What is paging and what problems does it solve?
Process sees memory as one contiguous space
in reality pages are scattered across actual hardware
each page the same size, efficiently uses memory and can have protection per page
Solves external fragmentation problem by using fixed size units in physical and virtual memory
Solves internal fragmentation by making the units small
What is a page table?
Table that maps pages in a process’ virtual memory to page frames in physical memory
How is address translation done with paging?
Virtual address has two parts: page number and offset
Page number corresponds to entry in page table
offset refers to offset from the base address of the page