Skip to main content
Logo image

Dive Into Systems: Exercises

Section 11.3 Locallity

Checkpoint 11.3.1. Locality.

    Accessing the same variable repeatedly is an example of what type of locality?
  • Spatial
  • Incorrect.
  • Temporal
  • Correct!
  • Both spatial and temporal
  • Incorrect
  • Neither spatial nor temporal
  • Incorrect.

Checkpoint 11.3.2. Locality.

    Accessing values at two nearby indices in an array is an example of what type of locality?
  • Spatial
  • Correct!
  • Temporal
  • Incorrect.
  • Both spatial and temporal
  • Incorrect
  • Neither spatial nor temporal
  • Incorrect.

Checkpoint 11.3.3. Locality.

    Consider the following snippet of C code:
    int scores[100];
    int i;
    for (i = 0; i < 100; i++) {
        scores[i] = 0;
    }
    
    Which type(s) of locality does this code exhibit?
  • Spatial
  • Don’t forget to consider the i variable.
  • Temporal
  • Incorrect.
  • Both spatial and temporal
  • Correct!
  • Neither spatial nor temporal
  • Incorrect.

Checkpoint 11.3.4. Locality.

    True or False: A programmer can control the degree of data locality employed in their program.
  • True
  • Correct!
  • False
  • Incorrect.
Hint.
Think about the example of row-major ordering.

Checkpoint 11.3.5. Cache Conflicts.

    How does a typical computer system determine what to keep in its CPU cache?
  • It keeps things that it has used in the past.
  • Correct!
  • Programmers provide hints about what will be needed in the future.
  • Incorrect.
  • Both A and B.
  • Incorrect
  • Neither A nor B
  • Incorrect.