0

The goal of this project is to take a previously created program which calculates a cross product on a matrix of data, and test page replacement algorithms on it.

The idea is to figure out how many pages are used by the program, and the order in which the various page numbers are referenced during a loop in which the cross product is calculated.

The page size is supposed to be limited to 4096 for testing purposes. I'm not entirely sure where to begin with figuring out the page reference string. Here's the loop it needs to be calculated in:

for(int i=0; i<6; i++)
{
    for(int j=0; j<6; j++)
    {
        x->result[i][j]+=array[i]*array[j]; //cross product algorithm                                         
                                             //performed on line
    }
}

Any help or advice that can be provided would be greatly appreciated, I'm pretty lost on where to start but once I have an idea of how to actually get the reference string I will be able to do the rest.

freelancer05
  • 77
  • 2
  • 6

1 Answers1

0

The page numbers referenced by the expression x->result[i][j]+=array[i]*array[j] are

  • (uintptr_t)(void *)&x->result[i][j]/4096
  • (uintptr_t)(void *)&array[i]/4096
  • (uintptr_t)(void *)&array[j]/4096

(provided that x->result[i][j], array[i] and array[j] don't cross page boundaries); the order in which they are referenced within one iteration is not defined by the language standard.

Armali
  • 18,255
  • 14
  • 57
  • 171