Can anyone tell me why applications run faster on Linux rather than bare metal?
Linux has context switches while a bare metal app doesn't.
I have inline assembly and I measure its execution time.In both executables the assembly I have inlined is exactly the same(you can see at the end the code I wrote.I compiled both with -O0 options. I compute and subract any overhead of syscall( clock_gettime for linux and XTime_GetTime for xilinx bare metal). I configured the chip for the bare metal only with the ARM core and nothing else.
I find it really weird...
Can anyone give me an idea why that is happening??
code snippet:
#define BENCHMARK(val)
t__asm__ __volatile__(
t"mov r4, %1
t"
t"mov r5, #0
t"
t"1:
t"
t"add r5,r5,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"mov r4 ,r4
t"
t"sub r4,r4,#1
t"
t"cmp r4, #0
t"
t"bne 1b
t"
t"mov %0 ,r5
t"
t:"=r" (val)
t: "r" (RUNS)
t: "r4","r5"
);