lkml.org 
[lkml]   [1997]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Utilizing rdtsc on i586?

On Wed, 30 Apr 1997, Harald Koenig wrote:

[...]
> it's not necessary to run this in kernel; using user mode is ok too:
>

plus the following is handy too:

> void main(void)
> {
> unsigned int cnt3, cnt2, cnt1;
> int i;
> printf("cc: started... ");

iopl(3);
__asm__("cli");

> __asm__(".byte 0x0f,0x31" : "=a" (cnt1), "=d" (cnt3));
> /* put code to time here */
> for(i=0;i<10000;i++);
> /* end code to time here */
> __asm__(".byte 0x0f,0x31" : "=a" (cnt2), "=d" (cnt3));

__asm__("sti");


> printf(" operation took %d cycles\n", cnt2-cnt1);
> }

you've got to run it as root, and better make no mistakes between cli and
sti ;)

-- mingo


\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.085 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site