operating systems - garryowen.csisdmz.ul.iegarryowen.csisdmz.ul.ie/~cs5212/resources/lect19.pdf ·...
Post on 14-Feb-2019
219 Views
Preview:
TRANSCRIPT
Virtual Memory – Silberschatz: §9
Operating Systems
Spring 2009-2010
CS5212
Virtual Memory – Silberschatz: §9
Outline
1 Virtual Memory – Silberschatz: §9IntroductionDemand Paging
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Outline
1 Virtual Memory – Silberschatz: §9IntroductionDemand Paging
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Background
Virtual memory: separation of user logical memory fromphysical memory
Only part of the program / program’s data structures needsto be in memory for executionLogical address space can therefore be much larger thanphysical address spaceAllows address spaces to be shared by several processesAllows for more efficient process creation
Virtual memory can be implemented via:Demand pagingDemand segmentation
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Virtual Memory That is Larger Than Physical Memory
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Virtual Address Space
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Shared Library Using Virtual Memory
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Outline
1 Virtual Memory – Silberschatz: §9IntroductionDemand Paging
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Demand Paging Basics
Bring a page into memory only when it is neededLess I/O neededLess memory neededFaster responseMore users
Page is needed because a reference was made to itif invalid reference then abortif not-in-memory then bring in to memory
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Valid-Invalid Bit
With each page table entry a valid-invalid bit is associated(v means in-memory, i not-in-memory)Initially valid-invalid bit is set to i on all entriesExample of a page table snapshot:
Frame # V/Ivvi
...ii
Page TableDuring address translation, if valid-invalid bit in page tableentry is i then this triggers a page fault
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Page Table When Some Pages Are Not in MainMemory
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Page Faulting
If there is a reference to a page, first reference to that pagewill trap to operating system: page faultOperating system looks at another table to decide whetherit is:
an invalid reference; if so then abortjust not in memory
Get empty frameMove page into frame (performed by the pager)Update tablesSet valid-invalid bit = vRestart the instruction that caused the page fault
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Steps in Handling a Page Fault
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Performance of Demand Paging
Page Fault Rate 0 ≤ ρ ≤ 1.0if ρ = 0, no page faultsif ρ = 1, every reference is a fault
Effective Access Time (EAT):
EAT = (1− ρ)×memory access+ρ× (page fault overhead
+paging out+paging in
+restart overhead)
CS5212
Virtual Memory – Silberschatz: §9IntroductionDemand Paging
Example of Demand Paging
Memory access time = 200 nanosecondsAverage page-fault service time = 8 millisecondsEffective Access Time
EAT = (1− ρ)× 200ns + ρ(8ms)
= (1− ρ)× 200ns + ρ(8,000,000)
= 200ns + ρ7,999,800
If one access out of 1,000 causes a page fault, then
EAT = 8.2ms
This is a slowdown by a factor of 40!!
CS5212
top related