Download presentation
Presentation is loading. Please wait.
Published byEric Thompson Modified over 9 years ago
1
ICOM 5007 - Noack Memory management Virtual memory Paging and segmentation Demand paging Memory management hardware
2
ICOM 5007 - Noack Virtual memory Reasons No program relocation – just remap memory Security – hardware keeps processes from interfering Efficiency – only needed memory is loaded Addresses Virtual address – what the CPU sees Physical address – to physical memory Page fault interrupt – whenever virtual address doesn’t map into physical address Normal operation First few lookups cause page faults and loading of memory blocks After a short time, repeated accesses in same blocks of memory usually work CPU Address translation Physical memory Virtual address Physical address Page Fault interrupt
3
ICOM 5007 - Noack The working set hypothesis Programs live monotonous lives Small loops of code or calling same function – these small blocks of code are used heavily Arrays or structures – program typically works in a few heavily used data areas Stack – activity is at the stack top Common statistics Hit ratio – percent of memory accesses that do not cause page fault interrupts (or cache hit ratio) Amount of memory needed vs block size Hit ratio vs number of blocks allowed and block size Typical tradeoffs Performance - block size – hit ratio – memory required for Various program types Number of processes Amount of physical memory
4
ICOM 5007 - Noack Paging and segmentation Ideas are familiar to 8086 programmers Segment Not of fixed size Access attributes – ownership, access rights (RO, RW, kernel/user) Few for any given process Each usually has a purpose Page Fixed size – always a power of 2 – often 4096 bytes Access attributes – ownership, access rights (RO, RW, kernel/user) Status and physical page number for each virtual page number As many as needed CPUSegmentationPaging Physical memory Virtual addressLinear addressPhysical address
5
ICOM 5007 - Noack Demand paging Basic idea – don’t load it until you need it Feasible because working set hypothesis is valid Won’t keep working unless some form of page replacement is used to eliminate unused physical pages Normal operation First few lookups cause page faults and loading of memory blocks After a short time, repeated accesses in same blocks of memory usually work Page table formats Direct – virtual physical Inverse - physical virtual Multilevel - virtual page directory page table physical
6
ICOM 5007 - Noack How paging works Address parts Page number which page Translated by paging hardware or software Offset Length=log 2 (page size) Not translated by paging – page is handled as a unit Translation – direct Virtual address used as index to page table – page table entry says either Physical page number is… Or I am on disk at … Or I am not valid Page numberoffset Address – virtual or physical offset Page number Directory number Address into multilevel page table
7
ICOM 5007 - Noack Multilevel paging and lookaside Steps Directory base is in a register Virtual directory number is used to look up page table base Page table is used to look up page table entry This gives physical page number or how to find it on disk Consequences Three memory accesses for each real memory transaction Remedy Transaction lookup buffer in hardware This remembers last few paging lookups This is what hit ratios are about
8
ICOM 5007 - Noack Page tables and page table entries Page table entry Physical page number or device/block location on disk Status Valid Modified (also called dirty) Accessed recently Privilege level Page directory entry Base of page table Privilege level Size of page table (if not fixed)
9
ICOM 5007 - Noack The page frame table An inverse table for all of physical memory Each page table entry results in a page frame table entry Not changed at context switch (why) Contains accessed and modified bits Used to find pages to swap out or discard Dirty pages are written back Clean ones are discarded Used to allocate clean pages and by pagedaemon
10
ICOM 5007 - Noack Memory management hardware
11
ICOM 5007 - Noack Memory management in Linux Hardware-independent memory management layer Adapts to 32 and 64-bit address widths Method is three-level page tables Entity64 bit32 bit Page directory10 bits10 bits Page middle10 bits0 bits Page table10 bits10 bits Page size13 bits12 bits Note: not all the 64 bits are used 43 bits already gives a 43 Tbyte space Page middle directory has size 1 for 32-bit architectures This allows same system calls for 32-bit and 64-bit architectures
12
ICOM 5007 - Noack Segmentation in Linux Almost doesn’t exist The main segments are all 4 GB, spanning the entire address space Kernel memory is actually in top GB (above 3 GB) User memory is in bottom 3 GB Register assignments are CS – either user or kernel code segment
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.