Section 12.4
Review Questions

The Principle of Locality

  1. What keeps a computer from thrashing? Why does virtual memory work as well as it does?
  1. Define the principle of locality.
  1. What do we call a place in a program where a small chunk of code is executed many, many times?
  1. Where are you more likely to see the principle of locality operating?
               in code
               
               in data
  1. Think of a time when the principle of locality could be seen in a region of data memory.
  1. In the following chunk of pseudo-C code, circle the likely hot spot.
     main() {
         int xyz, def, w, x, i;
     
         xyz = ....
         def = ....
         x = ....
     
         while (xyz < 5) {
              /* do something here... */
         }
     }