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:
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);

Sitting on one of those lovely Virgin trains down from Sheffield, with my laptop plugged into the 13A socket by the seat, I had a trawl through the kernel code to discover that there is a pretty good microsecond timer implemented there by (void) do_gettimeofday(struct timeval *tv).


Not as exciting as your solution, if you see what I mean :-).

jd

--

John Daragon                                          john@xxxxxxxxxx
argv[0] limited
Lambs Lawn Cottage,  Staple Fitzpaine,  Taunton,  TA3 5SL,  UK
v +44 (0) 1460 234068   f +44 (0) 1460 234069   m +44 (0) 7836 576127



--
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