Memory Management Flashcards
(21 cards)
What are memory management tasks?
- memory allocation
* Memory management techniques must efficiently allocate memory to processes - protection
* Processes need to be protected against intereference from other processes - sharing
* Processes may sometimes need to share data
Memory Management Techniques
- Fixed Partitioning
- Dynamic Partioning
- Simple Segmentation
- Virtual memory segmentation
- simple paging
- virtual memory paging
Fixed Partitioning
- Memory is dividing into partitions of ficed size; the size may vary between partitions
- A process can be loaded into any partition whose size is equal to or greater than the size of the process
- One-to-one mapping between partitions and processes
Internal Fragmentation
Internal Fragmentation refers to wasted space inside partitions whent the size of process is smaller than the size of the partitions
Fixed Partitioning Pros and Cons
Pros:
* Easy to understand and implement
Cons:
* Internal Fragmentation
* A pre-specified under limit on the number of processes
* A pre-specified upper limit on the size of the largest processes
Dynamic Partitioning
The parition sizes adjust to the size of processes
- One-to-one mapping between partitions and processes
Compactions
Refers to relocation of processes so that they occupy contiguous memory regions, thereby consolidating free memory into a single contiguous block
Dynamic Partitioning: Pros and Cons
Pros:
* No internal Fragmentation
* No limit on the number of processes or on the size of the largest process
Cons:
* External fragmentation
* Time is wasted on compaction
Simple Segmentation
Easch program is divided into segments(e.g text and data segments)
- Segments are loaded into memory as in dynamic partitioning
- All segments need to be loaded into memory, but they do not need to be contiguous
Simple Segmentaiton Pros and Cons
Pros:
* Easier to fit processes in memory than with dynamic partitioning
* no internal fragmentation
* No limit on the number of processes or on the size of the largest process
Cons:
* External fragmentation (less than dynamic partitioning)
* Time is wasted on compaction
Virtual Memory Segmentation
Refers to the use of disk storage as if it was main memory
Segments are loaded into memory as in dynamic partitioning, except that not all segments need to be loaded at the same time
Virtual Memory Segmentation Pros and Cons
Pros:
* Easier to fit processes in memory than with simple segmentation
* no internal fragmentation
* No limit on the number of processes or on the size of the largest process
Cons:
* More overhead required for virtual memory
* External fragmentation (less than dynamic partitioning)
* Time is wasted on compaction
Simple paging
Memory is divide into fixed-size frames of equal size
- each process divided into pages of the same size
Internal fragmentation is small since: - It only affects the last frame in each process
- the frame/page-size is fairly small
Simple paging pros and cons
Pros:
* No external fragmentation
* All pages fit perfectly into frames
Cons:
* (small) internal fragmentation
* Each process requires a page table (which consumes memory)
Virtual Memory Paging
Pages are loaded into frames as simple pages, except that not all pages need to be loaded at the same time
Virtual Memory paging Pros and Cons
Pros:
* Easier to fit processes in memory than with simple paging
* no external fragmentation
* all pages fit perfectly into frames
Cons:
* More overhead required for virtual memory
* (small) internal fragmentation
* each process requires a page tables (which consumes memory)
Protection and Sharing with Segmentation and Paging
Protection/sharing is generally easier with segmentation with paging since
* the segment table is smaller than the page table
* segments are more natural units for protection and sharing
Define Direct Memory Access (DMA).
Hardware feature that lets an I/O device transfer data directly to / from main memory without CPU copying each word.
How does an HDD use DMA?
Disk controller gathers a block, then the DMA controller streams that block over the bus into a pre-set RAM buffer.
What happens to the CPU during a DMA transfer?
CPU is free to execute other instructions; it’s only interrupted when the whole block finishes.
CPU-programmed I/O vs. DMA — key difference?
Programmed I/O: CPU moves every byte → high overhead. DMA: device + DMA engine move the block → low CPU load, higher throughput.