On Fri, Feb 25, 2011 at 5:15 PM, Daniel Baluta <daniel.baluta@xxxxxxxxx> wrote:
On Fri, Feb 25, 2011 at 8:22 PM, Mauro Romano Trajber <trajber@xxxxxxxxx> wrote:Can you post a pointer to your code and information about how you got
> Thanks Enrico and Daniel, you're right. glibc was caching getpid(); but this
> is not the root cause of this behavior.
> Going further, I decide to use call getpid without glibc, using
> syscall(SYS_getpid) to test this behavior and it happened again.
> Calling it once, the test consumes about 7k CPU cycles and 10 calls consumes
> about 10k CPU cycles.
> Any ideas ?
this numbers?
thanks,
Daniel.
#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <unistd.h> #include <sys/syscall.h> #include <sched.h> long mygetpid() { return syscall(SYS_getpid); } inline volatile long long RDTSC() { register long long TSC asm("eax"); asm volatile (".byte 15, 49" : : : "eax", "edx"); return TSC; } int main(int argc, char *argv[]) { cpu_set_t cpu; CPU_ZERO(&cpu); CPU_SET(0, &cpu); if (sched_setaffinity(0, sizeof(cpu), &cpu) < 0) { perror("sched_setaffinity"); exit(1); } int i, qtd = 0; if (argc == 2) { qtd = atoi(argv[1]); } long long start = RDTSC(); for (i = 0; i < qtd; i++) { mygetpid(); } long long end = RDTSC(); printf("%lld\n", (end - start)); return 0; }
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies