COMP2004
Programming Practice
2002 Summer School


Kevin Pulo
School of Information Technologies
University of Sydney


(page 1)


Assignment 3





(page 2)


Background




(page 3)


Addresses and pages




(page 4)


Pages diagram






(page 5)


Finding page numbers


= 91.045166...
= 91


(page 6)


Frames




(page 7)


Cache diagram





(page 8)


Accessing information




(page 9)


Loading pages




(page 10)


Cache misses




(page 11)


Writing to frames




(page 12)


Cache diagram revisited





(page 13)


Write-back




(page 14)


Types of cache miss




(page 15)


Your task




(page 16)


Your code




(page 17)


Classes




(page 18)


Creating Cache objects


CacheFactory::createCache(s);


(page 19)


Creation string format


lookahead check_frames



(page 20)


Main loop


char mode;
Cache::addr_t address;
while (cin >> mode >> address) {
if (mode == 'r') {
c->read(address);
} else if (mode == 'w') {
c->write(address);
}
outputStats(*c);
}


(page 21)


Cache typedefs




(page 22)


Output


void outputStats(const Cache &c) {
Cache::counter_t hits = c.getHits(),
misses = c.getMisses(),
missesWB = c.getMissesWB();

cout << hits << " " <<
misses << " " <<
missesWB << endl;
}


(page 23)


Paging algorithms





(page 24)


First In First Out (FIFO)




(page 25)


FIFO Example





(page 26)


Least Recently Used (LRU)






(page 27)


LRU Example





(page 28)


Pipelined LRU (PLRU)





(page 29)


Pipelining and lookahead list




(page 30)