Program Structure
Careful selection of data and programming structures can increase locality and lower page fault rate.
Example:
- Assume that each page is 4K bytes and we have about 64Mbytes of memory on the machine.
- Program 1
A: Array[1..10000, 1..10000] of integer;
for i = 1 to 10000
for j = 1 to 10000
A[i,j] = i*j;
- Program 2
A: Array[1..10000, 1..10000] of integer;
for j = 1 to 10000
for i = 1 to 10000
A[i,j] = i*j;