cs1550 week 11 project3 - university of...

71
CS 1550 Project 3-cont.

Upload: others

Post on 07-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

CS 1550Project 3-cont.

Page 2: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• No need to use qemu• You will write the simulator from scratch with Java, c++,Perl, or

Python• Read from memory traces text files• Count the number of events (pagefaults, page evictions, hits etc.)• Compare eviction algorithms

Page 3: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Simulate memory page allocation and page eviction algorithm• Your program will read from a memory trace• You will implement how loaded pages are evicted

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Page 4: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Since it is a 32-bit address space. • First 20 bits is used for the address• The rest is used for offset

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Page Address Page offset

Page 5: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Lets suppose you have 12KB of physical memory• Page has 4KB• Assume FIFO

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0

1

2

Page 6: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Lets suppose you have 12KB of physical memory• Page has 4KB• Assume FIFO

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0

1

2

Pagefault since it is not in the process table

Page 7: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Lets suppose you have 12KB of physical memory• Page has 4KB• Assume FIFO

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 190a7

1

2

Pagefault since it is not in the process table

Page 8: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Lets suppose you have 12KB of physical memory• Page has 4KB• Assume FIFO

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 190a7

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Page 9: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Lets suppose you have 12KB of physical memory• Page has 4KB• Assume FIFO

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 190a7

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Page 10: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• Lets suppose you have 12KB of physical memory• Page has 4KB• Assume FIFO

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 3856b

1 190af

2

Pagefault again

We need to evict someone!!

Page 11: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 - Virtual Memory Simulator

• You have to implement:• Opt (Clairvoyant)• FIFO• NRU• Clock

Page 12: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

Page 13: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7

1 3856b

2 190af

Pagefault again

Page 14: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Page 15: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Page 16: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Let’s analyze who will be needed furthest away in the trace

Page 17: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Page 18: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Page 19: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1 3856b 4

2 190af

Pagefault again

We need to evict someone!!

Page 20: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1 3856b 4

2 190af 3

Pagefault again

We need to evict someone!!

Page 21: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1 3856b 4

2 190af 3

Pagefault again

We need to evict someone!!

Page 22: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1

2 190af 3

Pagefault again

We need to evict someone!!

Page 23: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1

2 190af 3

Pagefault again

We need to evict someone!!

Page 24: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1 15216

2 190af 3

Pagefault again

We need to evict someone!!

Page 25: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Optimal algorithm

• Evicts the page that will not be used the longest in the future.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R3856bbe0 R

0 190a7 0

1 15216

2 190af 3

Pagefault again

Remember that this will change as the

memory trace progresses

Page 26: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – First In First Out(FIFO)

• Evicts the oldest page in memory.

Page 27: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – First In First Out(FIFO)

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 190a7

1 3856b

2 190af

Pagefault again

• Evicts the oldest page in memory.

Page 28: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – First In First Out(FIFO)

• Evicts the oldest page in memory.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 190a7

1 3856b

2 190af

Pagefault again

We need to evict someone!!

Page 29: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – First In First Out(FIFO)

• Evicts the oldest page in memory.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 3856b

1 190af

2

Pagefault again

We need to evict someone!!

Page 30: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – First In First Out(FIFO)

• Evicts the oldest page in memory.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 3856b

1 190af

2 15216

Pagefault again

Page 31: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – First In First Out(FIFO)

• Evicts the oldest page in memory.

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 3856b

1 190af

2 15216

Pagefault again

Next to be evicted

Page 32: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

Page 33: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

0 190a7

1 3856b

2 190af

Page 34: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 190a7

1 1 3856b

2 1 190af

Page 35: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Page 36: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

• Page Rank (Lower Rank -> higher chance of being evicted)

Rank Page State3 referenced, modified2 referenced, not modified

1 not referenced, modified0 not referenced, not modified

Page 37: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Page 38: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Rank Page State3 referenced, modified2 referenced, not modified

1 not referenced, modified0 not referenced, not modified

Page 39: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Rank Page State3 referenced, modified2 referenced, not modified

1 not referenced, modified0 not referenced, not modified

Page 40: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Rank Page State3 referenced, modified2 referenced, not modified

1 not referenced, modified0 not referenced, not modified

Page 41: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Rank32

10

Page 42: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Rank32

10

PagefaultWe need to evict someone!! But there are 2 Rank 2 pages.

Page 43: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Rank32

10

PagefaultWe need to evict someone!! But there are 2 Rank 2 pages. Chose at random between lowest rank

Page 44: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Rank32

10

PagefaultWe need to evict someone!! But there are 2 Rank 2 pages. Chose at random between lowest rank

Page 45: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Page 46: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

Has to be set to 0 periodically (e.g., every 10 memory accesses)

Page 47: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Not Recently Used (NRU)

• Evicts pages that are not being used. • Periodically resets referenced flag.• Pages are ranked according to Use and Modification

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Referenced Dirty0 0 0 190a7

1 0 1 3856b

2 0 0 190af

Has to be set to 0 periodically (e.g., every 10 memory accesses)

Page 48: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Page 49: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Page 50: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Page 51: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Pagefault

Page 52: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 1 0 190a7

1 1 1 3856b

2 1 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Pagefault

Page 53: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 0 0 190a7

1 1 1 3856b

2 1 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Pagefault

Page 54: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 0 0 190a7

1 0 1 3856b

2 1 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Pagefault

Page 55: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 0 0 190a7

1 0 1 3856b

2 0 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Pagefault

Page 56: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 0 0 190a7

1 0 1 3856b

2 0 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Pagefault

Page 57: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 0 0 190a7

1 0 1 3856b

2 0 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

R is 0 evict!

Pagefault

Page 58: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 0 0

1 0 1 3856b

2 0 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

R is 0 evict!

Pagefault

Page 59: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 1 0 15216

1 0 1 3856b

2 0 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

R is 0 evict!

Pagefault

Page 60: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Clock

• Keeps a pointer to the last examined page in a circular list• Pointer resets the Referenced bit to 0

• If R is 0 the page is evicted• Pointer tries to evict and moves to the next page when a page fault occur

Referenced Dirty0 1 0 15216

1 0 1 3856b

2 0 0 190af

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Remember to reset to 0 periodically as well

Page 61: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• Program UI

./vmsim –n <numframes> -a <opt|clock|fifo|nru> [-r <refresh>] <tracefile>

Page 62: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• Program UI

./vmsim –n <numframes> -a <opt|clock|fifo|nru> [-r <refresh>] <tracefile>

Specifies the number of Memory slots.

Page 63: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• Program UI

./vmsim –n <numframes> -a <opt|clock|fifo|nru> [-r <refresh>] <tracefile>

Specifies which algorithm to run

Page 64: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• Program UI

./vmsim –n <numframes> -a <opt|clock|fifo|nru> [-r <refresh>] <tracefile>

Specifies the periodicity of the refresh rate for Clock and NRU

Page 65: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• Program UI

./vmsim –n <numframes> -a <opt|clock|fifo|nru> [-r <refresh>] <tracefile>

Path to memory trace file

Page 66: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• Program UI

./vmsim –n <numframes> -a <opt|clock|fifo|nru> [-r <refresh>] <tracefile>

python vmsim.py –n 8 -a opt -r ./swim.trace

java vmsim.class –n 8 -a opt -r ./swim.trace

Page 67: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• Program UI

./vmsim –n <numframes> -a <opt|clock|fifo|nru> [-r <refresh>] <tracefile>

python vmsim.py –n 8 -a opt -r ./swim.trace

java vmsim.class –n 8 -a opt -r ./swim.trace

Page 68: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• As the simulation runs you should print in the following format for each memory reference.• hit • page fault – no eviction • page fault – evict clean • page fault – evict dirty

Page 69: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• As the simulation runs you should print in the following format for each memory reference.

c:> 190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Page 70: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• As the simulation runs you should print in the following format for each memory reference.

c:> python vmsim.py –n 8 -a opt -r ./swim.trace 190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R

Page 71: CS1550 week 11 project3 - University of Pittsburghpeople.cs.pitt.edu/~lol16/CS1550_fall18/data/CS1550_Project3_conti… · Project 3 -Virtual Memory Simulator •Since it is a 32-bit

Project 3 – Program interface

• As the simulation runs you should print in the following format for each memory reference.

c:> python vmsim.py –n 8 -a opt -r ./swim.trace

hit page fault – no eviction hit page fault – evict dirtypage fault – evict clean …

190a7c20 R3856bbe0 W190afc20 R15216f00 R190a7c20 R190a7c28 R190a7c28 R190aff38 R