Page 181 -
P. 181

APPENDIX 4A 151


             APPENDIX 4A PERFORMANCE CHARACTERISTICS
                                OF TWO-LEVEL MEMORIES


                  In this chapter, reference is made to a cache that acts as a buffer between main
                  memory and processor, creating a two-level internal memory. This two-level archi-
                  tecture exploits a property known as locality to provide improved performance over
                  a comparable one-level memory.
                       The main memory cache mechanism is part of the computer architecture, im-
                  plemented in hardware and typically invisible to the operating system.There are two
                  other instances of a two-level memory approach that also exploit locality and that
                  are, at least partially, implemented in the operating system: virtual memory and the
                  disk cache (Table 4.7). Virtual memory is explored in Chapter 8; disk cache is be-
                  yond the scope of this book but is examined in [STAL09]. In this appendix, we look
                  at some of the performance characteristics of two-level memories that are common
                  to all three approaches.
                  Locality

                  The basis for the performance advantage of a two-level memory is a principle
                  known as locality of reference [DENN68]. This principle states that memory refer-
                  ences tend to cluster. Over a long period of time, the clusters in use change, but over
                  a short period of time, the processor is primarily working with fixed clusters of
                  memory references.
                       Intuitively, the principle of locality makes sense. Consider the following line of
                  reasoning:
                    1. Except for branch and call instructions, which constitute only a small fraction
                       of all program instructions, program execution is sequential. Hence, in most
                       cases, the next instruction to be fetched immediately follows the last instruc-
                       tion fetched.
                    2. It is rare to have a long uninterrupted sequence of procedure calls followed by
                       the corresponding sequence of returns. Rather, a program remains confined to a


                  Table 4.7 Characteristics of Two-Level Memories
                                      Main Memory      Virtual Memory
                                         Cache            (paging)          Disk Cache

                                                                           6
                                                       6
                   Typical access time   5 : 1 (main memory  10 : 1 (main memory  10 : 1 (main memory
                   ratios            vs. cache)      vs. disk)           vs. disk)
                   Memory management  Implemented by   Combination of hardware  System software
                   system            special hardware  and system software
                   Typical block or page  4 to 128 bytes  64 to 4096 bytes (virtual  64 to 4096 bytes
                   size              (cache block)   memory page)        (disk block or pages)
                   Access of processor  Direct access  Indirect access   Indirect access
                   to second level
   176   177   178   179   180   181   182   183   184   185   186