Laboratory Exercises For Computer Science 211

Main Memory Structure

Main Memory Structure

Goals: This laboratory exercise provides experience with elements of cache memory.

Steps for this Lab:

  1. Review Sections 2.2.5 and 4.5.1 in the text.

  2. Consider the following cache line reference sequence:

    1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6

    Assume cache contains room for 4 cache lines. This could be organized by

    1. 4-way set-associative cache with 0 line bits (i.e.., LRU on all 4 locations),
    2. 2-way set-associative cache with 1 line bit,
    3. direct mapped cache with 2 line bits.

    Determine the number of cache hits and misses in each of these cases.

  3. Now consider a virtual paging system, where four pages may be stored in main memory and where the sequence of the previous problem reflects the sequence of page requests needed in a program.

    Determine the number of hits to main memory for each of the above replacement algorithms:

    1. FIFO, and
    2. FIFO combined with Second Chance.

  4. Solve problems 26 and 27 in Chapter 4 (page 301) in the text.

  5. Adapted from Computer Organization, A Top-Down Approach by Greg Scragg, McGraw-Hill, 1992.

    Recall the 90% rule: 90% of execution time typically involves 10% of the code.

    Assume that you have a cache capable of holding 50% of your code, and assume a cache line holds 8 instructions.

    1. If an instruction of a running program is selected at random from a code listing, what is the probability that it will be in cache.

    2. If execution was stopped after a random number of steps, what would the probability be that the next instruction would be in cache?

    3. Consider the overall running of the program. What is a likely cache hit ratio?

    In each case, give a brief justification of your answer.

    Extra Credit: Repeat problem 5, assuming that only 5% of the program fits in cache.

Only one write-up of each problem should be turned in for each group, and the writing of solutions should be shared by group members. Each member of a group must write up at least one problem, and each solution should be reviewed by all members of the group. After solutions are written (and revised as necessary) to the satisfaction of all group members, the solutions should be collected together and turned in as a single packet from the group.


This document is available on the World Wide Web as

     http://www.math.grin.edu/~walker/courses/211.fa99/labs/lab-cache.html

created December 1, 1999
last revised December 3, 1999