Measurement of TLB effects on a Cortex-A9
tl;dr -> Provide a proper MVCE.
This answer should be a comment but is too big to be posted as comment, so posting as answer instead:
I had to fix a bunch of syntax errors (missing semicolons) and declare undefined variables.
After fixing all those problems, the code did NOTHING (the program quit even prior to executing the first
mmap
. I'm giving the tip to use curly brackets all the time, here is your first and your second error caused by NOT doing so:
.
// after calloc:if(entries == NULL) perror("calloc failed"); exit(1);// after mmapif(entries[i] == MAP_FAILED) perror("mmap failed"); exit(1);
both lines just terminate your program regardless of the condition.
- Here you got an endless loop (reformatted, added curly brackets but no other change):
.
//Randomly access and init with random valuesn = -1;i = 0;while (++n < NB_ENTRIES -1) { //init with random value entries[i]->elmt = rand() % NB_ENTRIES; //loop till we reach the last element while (entries[entries[i]->elmt]->elmt != -1) { entries[i]->elmt++; if (entries[i]->elmt == NB_ENTRIES) { entries[i]->elmt = 0; } } i = entries[i]->elmt;}
First iteration starts by setting entries[0]->elmt
to some random value, then inner loop increments until it reaches LAST_ELEMENT
. Then i
is set to that value (i.e. LAST_ELEMENT
) and second loop overwrites end marker -1
to some other random value. Then it's constantly incremented mod NB_ENTRIES in the inner loop until you hit CTRL+C.
Conclusion
If you want help, then post a Minimal, Complete, and Verifiable example and not something else.