wpin 发表于 2003-10-23 15:36:43

帮忙解释一下这段程序

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
extern unsigned long cpu_khz;

// Setup function to read cpu cycles out of pentium class processor.
#define rdtsc2(low,high) \
   __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))

#else
………………
#endif

wpin 发表于 2003-10-23 15:38:09

调用是这样的
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
double cycles_d, khz_d;
unsigned long eax, edx;

rdtsc2(eax,edx);
cycles_d = (edx*4294967296.0)+eax;

khz_d = (double) cpu_khz;
return cycles_d/(khz_d*1.0e3);

Dragonfly 发表于 2003-10-23 21:07:04

search rdtsc()in google.

there is a good introduction on rdtsc on intel site.
页: [1]
查看完整版本: 帮忙解释一下这段程序