5.1 Memory Management Flashcards
Adresses
Logical
-Reference to a memory location independent of the current assignment of data to memory
Relative
-Address expressed as a location relative to some known point
Physical or Absolute
-The actual location in memory
Paging
Partition memory into small equal fixed-size chunks and divide each process into the same size chunks
Chunks of a process are PAGES
Chunks of memory are FRAMES
OS maintains a page table for each page in the process
-Contains frame location for each page in process
-Memory address consists of a page number and offset within the page
Segmentation
A program can be subdivided into segments
- Segments can vary in length & there is a max length to segments
Addressing has 2 parts
-A segment number & an offset
Key Points in Memory Management
Memory references are logical addresses dynamically translated into physical addresses at runtime
A process may be broken up into pieces that do not need to be located continuously in main memory
Execution of a Process
OS brings a few pieces of the program into main memory
Resident set - portion of process in main memory
An interrupt occurs when an address is needed that is not in main memory
OS places the process in a blocking state
Piece of process that contains the logical address is brought into main memory
Implications of New Strategy
More processes may be maintained in main memory
A process may be larger than all of main memory
Real & Virtual Memory
Real Memory - Main memory, the actual RAM Virtual Memory - Memory on disk - Allows for effective multiprogramming and relieves the user of tight constraints of main memory
Thrashing
A state in which the system spends most of its time swapping pieces rather than executing instructions
To avoid this, the OS tries to guess which pieces are least likely to be used in the near future
Principle of Locality
Program and data references within a process tend to cluster
Only a few pieces of a process will be needed over a short period of time
Therefore it is possible to make intelligent guesses about which pieces will be needed in the future, suggesting virtual memory may be effective
Support Needed for VM
Hardware must support paging and segmentation
Operating system must be able to manage the movement of pages and/or segments between secondary and main memory
Paging
Each process has its own page table
Each page table entry contains the frame number of the corresponding page in main memory
Two more things are needed
-Whether the page is in main memory or not
-Whether the contents of the page has been altered since it was last loaded
Page Tables
Page tables are also stored in virtual memory
When a process is running part of its page table is in main memory
Page Replacement
The page frame data table is used for page replacement
Pointers used to create several lists within the table
Kernel Memory Allocator
The kernel generates and destroys small tables and buffers frequently during the course of execution, each of which requires dynamic allocation
Most of these blocks significantly smaller than typical pages
Page Replacement
Based on the clock algorithm
The ‘use-bit’ is replaced with an 8-bit age variable
Periodically decrements the age bits
A form of least frequently used policy