东南大学操作系统课件(汪芸老师版)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Chapter 9: Virtual Memory
Agenda
g
•Virtual Memory
Vi t l M
Demand Paging •Demand Paging •Page Replacement •Allocation of Frames •Thrashing
Local principle of program
•Local principle of program
•Virtual memory
–separation of user logical memory from physical memory.
–Only part of the program needs to be in memory for execution
–Allows address spaces to be shared by several
processes
–Allows for more efficient process creation
y p
•Virtual memory can be implemented via:–Demand paging
–Demand segmentation
Demand segmentation
Virtual-address Space
⇒
Shared Library Using Virtual
Memory
Agenda
g
•Virtual Memory
Vi t l M
Demand Paging •Demand Paging •Page Replacement •Allocation of Frames •Thrashing
g g
Demand Paging
•Bring a page into memory only when it is needed
–Less I/O needed
–Less memory needed
Less memory needed
–Faster response
–More users
g g
Demand Paging
•Page is needed ⇒reference to it
–invalid reference ⇒abort
⇒not-in-memory ⇒bring to memory •Lazy swapper–never swaps a page into L i t memory unless page will be needed
–Swapper that deals with pages is a pager
Transfer of a Paged Memory to Contiguous Disk Space
to Contiguous Disk Space
g
Page Fault
•If there is a reference to a page, first
reference to that page will trap to reference to that page will trap to
operating system:
page fault
page fault
Page Fault
g
1.Operating system looks at another table to Operating system looks at another table to decide:
–Abort
Abort
–Just not in memory
2.Get empty frame
2Get empty frame
3.Swap page into frame
4.Reset tables
4R t t bl
5.Set validation bit = v
6.Restart the instruction that caused the page fault
p g g Steps in Handling a Page Fault
Performance of Demand Paging
g g
•Page Fault Rate 0 ≤p≤1.0
Page Fault Rate010
–if p= 0 no page faults
–if p= 1, every reference is a fault •Effective Access Time (EAT)
EAT(1)
EAT = (1 –p) x memory access
p(p g p p g
+ (page fault overhead + swap page out + swap page in + restart overhead)
p
Example
Memory access time = 200 nanoseconds •Memory access time=200nanoseconds
•Average page-fault service time = 8 milliseconds
•EAT = (1 –p) x 200 + p (8 milliseconds) EAT=(1–p)x200+p(8milliseconds)
= 200 + p x 7,999,800
•If one access out of 1,000 causes a page fault, then EAT 8.2 microseconds. fault then EAT=82microseconds
This is a slowdown by a factor of 40!!