I am running our own OS. I want to measure OS overhead using the TSC on an intel i7-2600 multicore processor.
I have the following application:
Code: Select all
int main()
{
for(int i = 0; i < REP; i++)
run(i)
}
void run(int test)
{
create threads
join threads
delete threads
print the collected TSC values
}
Code: Select all
void Thread::sleep(..)
{
//disables interrupts and gets a spin lock
TSC::Time_Stamp start = TSC::time_stamp();
//performs some operations
_wakeup_tsc[_wakeup_counter] = TSC::time_stamp() - start;
_wakeup_counter++;
//enables interrupts and releases the spin lock
}
static TSC::Time_Stamp time_stamp() {
Time_Stamp ts;
ASMV("rdtsc" : "=A" (ts) : );
return ts;
}
I understand that if I change the repetitions, the compiler (g++) will change the memory addresses in the generated system image. Is there a reasonable explanation for this behavior? Maybe, something related to memory banks accesses? I cannot understand how the read TSC values change so much.
Best regards,
Giovani