Title: Outline
1Outline
- Class evaluation
- Announcement
- Virtual memory
- Overview
- Page replacement algorithms
Please turn in your Homework 5 before class
week14-2.ppt 2003
2Class Evaluation
Session Time Course ID
Session 2 0905-0955 005777
Session 3 1115-1205 005802
Session 4 1220-110 005645
Session 6 0800-0850 005808
CGS5765
Session 3 1115-1205 005635
Session 4 1220-110 005605
3Announcement
- Recitation class tomorrow (Nov. 26, 2003)
- I will be in Love 301 to answer questions
regarding Lab3 and others - The attendance is not required
4Virtual Memory
- Question
- Given the memory mapping schemes we have covered
so far, can we run a program that is larger than
the physical memory? - Why or why not?
5Time and space multiplexing
- The processor is a time resource
- It can only be time multiplexed
- Memory is a space resource
- We have looked at space multiplexing of memory
- We divide the memory into pages and segments
- We have several processes in the memory at the
same time sharing the memory - Now we will look at time multiplexing of memory
6Time and space multiplexing of hotel rooms
7Time multiplexing memory
- Swapping
- move part/whole programs in and out of memory (to
disk or tape) - allowed time-sharing in early OSs
- Overlays
- move parts of program in and out of memory (to
disk or tape) - allowed the running of programs that were larger
than the physical memory available - widely used in early PC systems
8Overlays
- Keep in memory only those instructions and data
that are needed at any given time. - Needed when process is larger than amount of
memory allocated to it. - Implemented by user, no special support needed
from operating system, programming design of
overlay structure is complex
9Overlays cont.
10Swapping
- A process can be swapped temporarily out of
memory to a backing store, and then brought back
into memory for continued execution. - Backing store fast disk large enough to
accommodate copies of all memory images for all
users must provide direct access to these memory
images. - Major part of swap time is transfer time total
transfer time is directly proportional to the
amount of memory swapped. - Modified versions of swapping are found on many
systems, i.e., UNIX and Microsoft Windows.
11Schematic View of Swapping
12Swapping
13Virtual memory
14Implementation of virtual memory
- Virtual memory allows
- time multiplexing of memory
- users to see a larger (virtual) address space
than the physical address space - the operating system to split up a process into
physical memory and secondary memory - Implementation requires extensive hardware
assistance and a lot of OS code and time - but it is worth it
15Implementation of virtual memory cont.
- Separation of user logical memory from physical
memory. - Only part of the program needs to be in memory
for execution. - Logical address space can therefore be much
larger than physical address space. - Need to allow pages to be swapped in and out.
- Virtual memory can be implemented via
- Demand paging
- Demand segmentation
16Demand Paging
- Bring a page into memory only when it is needed.
- Less I/O needed
- Less memory needed
- Faster response
- More users
- Page is needed ? reference to it
- invalid reference ? abort
- not-in-memory ? bring to memory
17Valid-Invalid Bit
- With each page table entry a validinvalid bit is
associated(1 ? in-memory, 0 ? not-in-memory) - Initially validinvalid but is set to 0 on all
entries. - Example of a page table snapshot.
- During address translation, if validinvalid bit
in page table entry is 0 ? page fault.
18Page Fault
- If there is ever a reference to a page, first
reference will trap to OS ? page fault - OS looks at another table to decide
- Invalid reference ? abort.
- Just not in memory.
- Get empty frame.
- Page replacement find some page frame in
memory, but not really in use, swap it out - Swap page into the frame.
- Reset tables, validation bit 1.
19Modified bit
- Most paging hardware also has a modified bit in
the page table entry - which is set when the page is written to
- This is also called the dirty bit
- pages that have been changed are referred to as
dirty - these pages must be written out to disk because
the disk version is out of date
20Performance of Demand Paging
- Page Fault Rate 0 ? p ? 1.0
- if p 0 no page faults
- if p 1, every reference is a fault
- Effective Access Time (EAT)
- EAT (1 p) x memory access
- p (page fault overhead
- swap page out
- swap page in
- restart overhead)
21Demand Paging Performance Example
- Memory access time 1 microsecond
- 50 of the time the page that is being replaced
has been modified and therefore needs to be
swapped out. - Swap Page Time 10 msec 10,000 msec
- EAT (1 p) x 1 p (15000)
- 1 15000 p (in msec)
22Locality
- Programs do not access their address space
uniformly - they access the same location over and over
- Spatial locality processes tend to access
location near to location they just accessed - because of sequential program execution
- because data for a function is grouped together
- Temporal locality processes tend to access data
over and over again - because of program loops
- because data is processed over and over again
23Practicality of paging
- Paging only works because of locality
- at any one point in time programs dont need most
of their pages - Page fault rates must be very, very low for
paging to be practical - like one page fault per 100,000 or more memory
references
24Demand paging Summary
- Demand paging
- Bring a page into memory only when it is needed
- Page fault
- First reference to a page not in memory generates
a page fault - Page fault is handled by the O.S
- Needs an empty page frame
25Page replacement
- Page replacement
- When there is no empty frame in memory, we need
to find a page to replace - Write it out to the swap area if it has been
changed since it was read in from the swap area - Dirty bit or modified bit
- which page to remove from memory to make room for
a new page - We need a page replacement algorithm
- Two categories of replacement algorithms
- Static paging algorithms always replace a page
from the process that is bringing in a new page - Dynamic paging algorithm can replace any page
26Page references
- Processes continually reference memory
- and so generate a sequence of page references
- The page reference sequence tells us everything
about how a process uses memory - For a given size, we only need to consider the
page number - If we have a reference to a page, then
immediately following references to the page will
never generate a page fault - 0100, 0432, 0101, 0612, 0102, 0103, 0104, 0101,
0611, 0102, 0103 - 0104, 0101, 0610, 0103, 0104, 0101, 0609, 0102,
0105 - Suppose the page size is 100 bytes, what is the
page reference sequence? - We use page reference sequences to evaluate
paging algorithms
27Page replacement algorithms
- The goal of a page replacement algorithm is to
produce the fewest page faults - We can compare two algorithms
- on a range of page reference sequences
- Or we can compare an algorithm to the best
possible algorithm - We will start by considering static page
replacement algorithms
28Optimal replacement algorithm
- The one that produces the fewest possible page
faults on all page reference sequences - Algorithm replace the page that will not be used
for the longest time in the future - Problem it requires knowledge of the future
- Not realizable in practice
- but it is used to measure the effectiveness of
realizable algorithms
29Beladys Optimal Algorithm
- Replace page that will not be used for longest
period of time. - Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
30Beladys Optimal Algorithm
- Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1
0 0 2 3
FWD4(2) 1 FWD4(0) 2 FWD4(3) 3
31Beladys Optimal Algorithm
- Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2
2 1 0 0 0 2 3 1
FWD4(2) 1 FWD4(0) 2 FWD4(3) 3
32Beladys Optimal Algorithm
- Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 1 0 0 0 0 0 2 3 1 1 1
33Beladys Optimal Algorithm
- Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 2 1 0 0 0 0 0 3 2 3 1 1 1 1
FWD7(2) 2 FWD7(0) 3 FWD7(1) 1
34Beladys Optimal Algorithm
- Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 2 2 2 0 1 0 0 0 0 0 3 3 3 3 2 3 1 1 1 1
1 1 1
FWD10(2) ? FWD10(3) 2 FWD10(1) 3
35Beladys Optimal Algorithm
- Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 2 2 2 0 0 0 1 0 0 0 0 0 3 3 3 3 3 3 2 3
1 1 1 1 1 1 1 1 1
FWD13(0) ? FWD13(3) ? FWD13(1) ?
36Beladys Optimal Algorithm
- Replace page with maximal forward distance yt
max xeS t-1(m)FWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 2 2 2 0 0 0 0 4 4 4 1 0 0 0 0 0 3 3 3 3 3 3
6 6 6 7 2 3 1 1 1 1 1 1 1 1 1 1 1 5 5
10 page faults
- Perfect knowledge of R ? optimal performance
- Impossible to implement
37Theories of program behavior
- All replacement algorithms try to predict the
future and act like the optimal algorithm - All replacement algorithms have a theory of how
program behave - they use it to predict the future, that is, when
pages will be referenced - then the replace the page that they think wont
be referenced for the longest time.
38Random page replacement
- Algorithm replace a page randomly
- Theory we cannot predict the future at all
- Implementation easy
- Performance poor
- but it is easy to implement
- but the best case, worse case and average case
are all the same
39Random page replacement
40Random Replacement
- Replaced page, y, is chosen from the m loaded
page frames with probability 1/m
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 1 2
2 1 3
2 1 3
2 1 0
3 1 0
3 1 0
3 1 2
0 1 2
0 3 2
0 3 2
0 6 2
4 6 2
4 5 2
7 5 2
2 0 3
2 0
2
41FIFO page replacement
- Algorithm replace the oldest page
- Theory pages are used for a while and then stop
being used - Implementation easy
- Performance poor
- because old pages are often accessed, that is,
the theory if FIFO is not correct
42FIFO page replacement
43First In First Out (FIFO)
- Replace page that has been in memory the longest
yt max xeS t-1(m)AGE(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2
1 1 0 0 0 2 3 3
44First In First Out (FIFO)
- Replace page that has been in memory the longest
yt max xeS t-1(m)AGE(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1
0 0 2 3
AGE4(2) 3 AGE4(0) 2 AGE4(3) 1
45First In First Out (FIFO)
- Replace page that has been in memory the longest
yt max xeS t-1(m)AGE(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2
1 1 0 0 0 2 3 3
AGE4(2) 3 AGE4(0) 2 AGE4(3) 1
46First In First Out (FIFO)
- Replace page that has been in memory the longest
yt max xeS t-1(m)AGE(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2
1 1 0 0 0 2 3 3
AGE5(1) ? AGE5(0) ? AGE5(3) ?
47Beladys Anomaly
- FIFO with m 3 has 9 faults
- FIFO with m 4 has 10 faults
48Least Frequently Used (LFU)
- Replace page with minimum use yt
min xeS t-1(m)FREQ(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1
0 0 2 3
FREQ4(2) 1 FREQ4(0) 1 FREQ4(3) 1
49Least Frequently Used (LFU)
- Replace page with minimum use yt
min xeS t-1(m)FREQ(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2
2 1 0 0 1 2 3 3
FREQ4(2) 1 FREQ4(0) 1 FREQ4(3) 1
50Least Frequently Used (LFU)
- Replace page with minimum use yt
min xeS t-1(m)FREQ(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 1 0 0 1 1 1 2 3 3 3 0
FREQ6(2) 2 FREQ6(1) 1 FREQ6(3) 1
51Least Frequently Used (LFU)
- Replace page with minimum use yt
min xeS t-1(m)FREQ(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 1 0 0 1 1 1 2 3 3 3 0
FREQ7(2) ? FREQ7(1) ? FREQ7(0) ?
52LRU page replacement
- Least-recently used (LRU)
- Algorithm remove the page that hasnt been
referenced for the longest time - Theory the future will be like the past, page
accesses tend to be clustered in time - Implementation hard, requires hardware
assistance (and then still not easy) - Performance very good, within 30-40 of optimal
53LRU model of the future
54LRU page replacement
55Least Recently Used (LRU)
- Replace page with maximal backward distance yt
max xeS t-1(m)BKWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1
0 0 2 3
BKWD4(2) 3 BKWD4(0) 2 BKWD4(3) 1
56Least Recently Used (LRU)
- Replace page with maximal backward distance yt
max xeS t-1(m)BKWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2
1 1 0 0 0 2 3 3
BKWD4(2) 3 BKWD4(0) 2 BKWD4(3) 1
57Least Recently Used (LRU)
- Replace page with maximal backward distance yt
max xeS t-1(m)BKWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1
1 1 0 0 0 2 2 3 3 3
BKWD5(1) 1 BKWD5(0) 3 BKWD5(3) 2
58Least Recently Used (LRU)
- Replace page with maximal backward distance yt
max xeS t-1(m)BKWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1 1
1 1 0 0 0 2 2 2 3 3 3 0
BKWD6(1) 2 BKWD6(2) 1 BKWD6(3) 3
59Least Recently Used (LRU)
- Replace page with maximal backward distance yt
max xeS t-1(m)BKWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1 1
1 3 3 3 0 0 0 6 6 6 7 1 0 0 0 2 2 2 1 1 1 3 3
3 4 4 4 2 3 3 3 0 0 0 2 2 2 1 1 1 5 5
60Least Recently Used (LRU)
- Replace page with maximal backward distance yt
max xeS t-1(m)BKWDt(x)
Let page reference stream, R 2031203120316457
Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2
2 2 3 2 2 2 2 6 6 6 6 1 0 0 0 0 0 0 0 0 0 0 0 0
4 4 4 2 3 3 3 3 3 3 3 3 3 3 3 3 5 5 3
1 1 1 1 1 1 1 1 1 1 1 1 7
- Backward distance is a good predictor of forward
distance -- locality
61Approximating LRU
- LRU is difficult to implement
- usually it is approximated in software with some
hardware assistance - We need a referenced bit in the page table entry
- turned on when the page is accessed
- can be turned off by the OS
62First LRU approximation
- When you get a page fault
- replace any page whose referenced bit is off
- then turn off all the referenced bits
- Two classes of pages
- Pages referenced since the last page fault
- Pages not referenced since the last page fault
- the least recently used page is in this class but
you dont know which one it is - A crude approximation of LRU
63Second LRU approximation
- Algorithm
- Keep a counter for each page
- Have a daemon wake up every 500 ms and
- add one to the counter of each page that has not
been referenced - zero the counter of pages that have been
referenced - turn off all referenced bits
- When you get a page fault
- replace the page whose counter is largest
- Divides pages into 256 classes
64LRU and its approximations
65A clock algorithm
66Clock algorithms
- Clock algorithms try to approximate LRU but
without extensive hardware and software support - The page frames are (conceptually) arranged in a
big circle (the clock face) - A pointer moves from page frame to page frame
trying to find a page to replace and manipulating
the referenced bits - We will look at three variations
- FIFO is actually the simplest clock algorithm
67Basic clock algorithm
- When you need to replace a page
- look at the page frame at the clock hand
- if the referenced bit 0 then replace the page
- else set the referenced bit to 0 and move the
clock hand to the next page - Pages get one clock hand revolution to get
referenced
68Second chance algorithm
- When you need to replace a page
- look at the page frame at the clock hand
- if (referencedBit0 modifiedBit0)then
replace the page - else if(referencedBit0 modifiedBit1)then
set modifiedBit to 0 and start writing the page
to disk and move on - else set referencedBit to 0 and move on
- Dirty pages get a second chance because they are
more expensive to replace
69Clock algorithm flow chart
70Stack Algorithms
- Some algorithms are well-behaved
- Inclusion Property Pages loaded at time t with m
is also loaded at time t with m1
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 3 1 1 1
1 2 2 2
LRU
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 0 1 1 1
1 2 2 2 3 3
71Stack Algorithms
- Some algorithms are well-behaved
- Inclusion Property Pages loaded at time t with m
is also loaded at time t with m1
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 3 3 1 1 1
1 1 2 2 2 0
LRU
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 0 0 1 1 1
1 1 2 2 2 2 3 3 3
72Stack Algorithms
- Some algorithms are well-behaved
- Inclusion Property Pages loaded at time t with m
is also loaded at time t with m1
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 3 3 3 1 1
1 1 0 0 2 2 2 2 1
LRU
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 0 0 0 1 1
1 1 1 1 2 2 2 2 2 3 3 3 3
73Stack Algorithms
- Some algorithms are well-behaved
- Inclusion Property Pages loaded at time t with m
is also loaded at time t with m1
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 3 3 3 4 1
1 1 1 0 0 0 2 2 2 2 1 1
LRU
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 2 2 2 2 2 4 3 3 3 3 3
74Stack Algorithms
- Some algorithms are well-behaved
- Inclusion Property Pages loaded at time t with m
is also loaded at time t with m1
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 3 3 3 4 4 4
2 2 2 1 1 1 1 0 0 0 0 0 0 3 3 2 2 2 2 1 1 1
1 1 1 4
LRU
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 0 0 0 0 0 0
0 0 4 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 4 4
4 4 3 3 3 3 3 3 3 3 3 2 2 2
75Stack Algorithms
- Some algorithms are well-behaved
- Inclusion Property Pages loaded at time t with m
is also loaded at time t with m1
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 3 3 3 4 4 4
4 4 4 1 1 1 1 0 0 0 0 0 2 2 2 2 2 2 2 1 1 1
1 1 3 3
FIFO
Frame 0 1 2 3 0 1 4 0 1 2 3 4 0 0 0 0 0 0 0 4 4 4
4 3 3 1 1 1 1 1 1 1 0 0 0 0 4 2 2 2 2 2 2 2
1 1 1 1 3 3 3 3 3 3 3 2 2 2
76Dynamic Paging Algorithms
- The amount of physical memory -- the number of
page frames -- varies as the process executes - How much memory should be allocated?
- Fault rate must be tolerable
- Will change according to the phase of process
- Need to define a placement replacement policy
- Contemporary models based on working set
77Working Set Principle
- Process pi should only be loaded and active if it
can be allocated enough page frames to hold its
entire working set - The size of the working set is estimated using w
- Unfortunately, a good value of w depends on the
size of the locality - Empirically this works with a fixed w
78Working set
- A page in memory is said to be resident
- The working set of a process is the set of pages
it needs to be resident in order to have an
acceptable low paging rate. - Operationally
- Each page reference is a unit of time
- The page reference sequence is r1, r2, , rT
where T is the current time - W(T,t) p p rt where T-t lt t lt T is the
working set, where t is the window size
79The Working Set Window
ri
R 0 3 1 2 1 1 0 3 0 1 2
W3
The Window
At virtual time i-1 working set 0, 1
At virtual time i working set 0, 1, 3
80Program phases
- Processes tend to have stable working sets for a
period of time called a phase - Then they change phases to a different working
set - Between phases the working set is unstable
- and we get lots of page faults
81Working set phases
82Working set algorithm
- Algorithm
- Keep track of the working set of each running
process - Only run a process if its entire working set fits
in memory called working set principle
83Working set algorithm example
w3
w4
84Working set algorithm example cont.
w9
85Working set algorithm example cont.
w 4
86Implementing Working Set Algorithm
- Too hard to implement so this algorithm is only
approximated - WSClock algorithm
- A clock algorithm that approximates the working
set algorithm - It needs to keep the last reference time of each
page frame - When the reference bit is set, the last reference
time was set to the current time - When a page fault occurs
- Inspect each frame as in the clock algorithm
- When a frames reference bit is set, then
determine whether it is in the working set by
comparing the last reference time
87Evaluating paging algorithms
- Mathematical modeling
- powerful where it works
- but most real algorithms cannot be analyzed
- Measurement
- implement it on a real system and measure it
- extremely expensive
- Simulation
- Test on page reference traces
- reasonably efficient
- effective
88Performance of paging algorithms
89Thrashing
- VM allows more processes in memory, so one is
more likely to be ready to run - If CPU usage is low, it is logical to bring more
processes into memory - But, low CPU use may to due to too many pages
faults because there are too many processes
competing for memory - Bringing in processes makes it worse, and leads
to thrashing
90Thrashing Diagram
- There are too many processes in memory and no
process has enough memory to run. As a result,
the page fault is very high and the system spends
all of its time handling page fault interrupts.
91Load control
- Load control deciding how many processes should
be competing for page frames - too many leads to thrashing
- too few means that memory is underused
- Load control determines which processes are
running at a point in time - the others have no page frames and cannot run
- CPU load is a bad load control measure
- Page fault rate is a good load control measure
92Load control and page replacement
93Two levels of scheduling
94Load control algorithms
- A load control algorithm measures memory load and
swaps processes in and out depending on the
current load - Load control measures
- rotational speed of the clock hand
- average time spent in the standby list
- page fault rate
95Page fault frequency load control
- L mean time between page faults
- S mean time to service a page fault
- Try to keep L S
- if L lt S, then swap a process out
- if L gt S, then swap a process in
- If L S, then the paging system can just keep up
with the page faults
96Windows NT Paging System
Virtual Address
Space
Primary Memory
Paging Disk (Secondary Memory)
Supv space
User space
97Windows Address Translation
Virtual page number
Line number
Page Directory
Page Table
Byte Index
a
b
A
Page Directory
c
Page Tables
B
C
Target
Page
Target Byte
98Linux Virtual Address Translation
99NT Memory-mapped Files
Secondary memory
Ordinary file
- Open the file
- Create a section object (that maps file)
- Identify point in address space to place the file
Executable memory
Memory mapped files
Section object
100NT Memory-mapped Files cont.
101Summary
- Virtual memory
- Time multiplexing of primary memory
- Can run a program larger than the primary memory
- Separates logical and physical memory address
spaces through memory hierarchy
102Summary cont.
- Demand paging
- Bring a page into primary memory only when it is
needed - When the referenced page is valid but not in
memory - Get an empty frame
- If no empty frame, use page replacement algorithm
to find a frame and swap it out if needed - Swap the reference page in
- Update the page table
103Have A Wonderful Thanskgiving