Consider the following C function executed in an OS with paging where the page size is 4 kilobytes. Further, assume that the system employs a 32-entry direct mapped TLB.
int *alloc_and_init()
{
int counter, value=0, size=2048;
int * new_ptr = malloc (size * sizeof (int));
/* Assume sizeof (int) = 4 and new_ptr is 4KB aligned */
for (counter=0; counter < size ; new_ptr++,counter++)
*new_ptr = value;
return new_ptr;
}
Assuming no page faults and no context switches during the execution of the program, what is the number of TLB misses during the execution of the for loop?
1
0
2
1
3
2048
4
2