CSE 7343/5343, Spring 2003
Topic 2-2: Memory Management
Prof. Jeff Tian, CSE/SoE/SMU, Dallas, TX 75275
tian@engr.smu.edu; www.engr.smu.edu/~tian/class/7343.03s
- Dates: 3/4-3/11.
- Reading: Ch 9.
Memory: User vs. System Views
- user view: (mostly contiguous) blocks
- "logical memory"
- access within the block
- should be shielded from specific implementations
- final execution time: need to be mapped to physical memory
- system view: allocated to different users/processes/jobs
- physical memory
- associated facilities to manage memory
software: mapping tables, etc.
hardware: protection, etc.
- different ways to manage memory
- linking logical to physical memory
- logical address from CPU
- physical address in mem addr register
- mapping
- example: Fig 9.2 (p.277)
- when the mapping/binding takes place?
- usually multi-step in modern OS
- compile time
if fixed, absolute address/code
- load time
if fixed, relocatable address/code
- execution time
- address binding: Fig 9.1 (p.275)
- treat as one-step mapping in subsequent discussions
Memory: Loading and Swapping
- loading before execution
at process creation
- dynamic loading and virtual memory
- not everything needed all the time
- older systems/OS: complete program/data loaded before execution
- newer ones: partially loaded
- dynamic loading: when needed or anticipated
- consequence: appear to have more resources
than actually/physically available
- virtual memory/virtual machine concept
through overlays (reclaim/reuse)
- related: dynamic linking
- swapping
- main memory and backing store
- memory scheduling: similar to CPU scheduling
- swap in/out or roll in/out
- typically refer to complete program/data instead of partial
partial => dynamic loading/replacement
Basic Memory Management Schemes
- overall schemes:
- contiguous memory allocation
- segmentation
- paging
- virtual memory (next chapter)
- contiguous memory allocation
- hardware support/protection
- example: Fig 9.5 (p.284)
- system memory table
- allocation: dynamic storage allocation problem
- algorithms: 1st/best/worst fit
- why?
- potential problems: fragmentation
- also internal fragmentation (allocated, but not used)
- solution: compaction
- time consuming
- main problem: fragmentation
- solution: other memory management schemes
Memory Management: Segmentation
- motivation: fragmentation problem for contiguous allocation
- smaller blocks of memory => segments
- overall organization: 2 levels
segments
offsets within segments
- similar view: user vs OS
related drawback: user must be aware of
(memory management implementation not shielded from users)
- mapping: Fig 9.17 (p.305)
- segment table: limit and base information
- support user view of segmented memory (Fig 9.16, p.304)
- protection: limit
- sharing: non-exclusive segment
- alleviate the fragmentation problem of contiguous memory allocation
- but still have (minor) fragmentation problem
internal due to allocation
external due to size restrictions
Memory Management: Paging
- motivation and historical perspective
- ideas related to segmentation
- user shouldn't be required to have the knowledge of specific implementations
(info. hiding)
- transparency (related to above)
- segment size => uniformity
- protection concerns (limit check)
- still addresses fragmentation problem
- basic ideas of paging
- can be viewed as specialized segmentation
- each segment/page of the same size
- page number (similar to segment base) +
- page offset (similar to offset within segment)
- mapping: Fig 9.6 (p.288)
- logical "pages" into physical "frames"
- same offset from the page/frame base
- similar to Fig. 9.17
- fixed size: not need to check size limit
- result: simpler page table than segment table
- most likely basis for virtual memory (Ch. 10)
- sharing: at page level
- comparison with segmentation:
- pages generally much smaller than segments
(therefore, the following)
- larger page table
- less external fragmentation
- internal fragmentation still exist,
but limited by page size)
- mapping operations
- other comparisons: /protection/sharing:
- logical units more meaningful
- implementation by segment vs page
- page/segment with different information
=> may need to split
- other comparison: view/transparency/etc.
- paging implementation
- page table
- fast memory (cache)
TLB (translation look-aside buffer)
- frame management: pool of available/free frame
- protection: at the page level too
- valid vs. invalid pages
- multilevel paging: similar to tree-structure
related: mixing segmentation with paging
- details in book
Prepared by Jeff Tian
(tian@engr.smu.edu).
Last update: March 6, 2003.