D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Interesting diagnostic problem

 

Robin Cornelius wrote:

I will have to lookup what i did at work and post it, but it uses an inline asembler call to access the CPU clock count register directly.


Here it is :-

#define PSCHED_GET_TIME(stamp) ({u32 hi, lo; __asm__ __volatile(".byte 0x0f,0xa2"); __ asm __volatile(".byte 0x0f,0x31" : "=a" (lo), "=d" (hi)); (stamp)=(((u64)hi<32)+lo);});

and to use it :-


u64 start,end; long time;

PSCHED_GET_TIME(start);
mdelay(1);
PSCHED_GET_TIME(end);
time=end-start;
printk("There are %ld clocks per ms\n",time);

Hope this helps

Robin








-- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe. FAQ: www.dcglug.org.uk/linux_adm/list-faq.html