[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] En ordentlig timing



In article <sslug@sslug>, "Anders Melchiorsen"
<sslug@sslug> wrote:

> Peter Aagaard Kristensen <sslug@sslug> skrev den 02-Nov-01:
> 
>>  >Selv kernen laver busy wait hvis den skal vente i millisekunder.
>> 
>> Hvilke tidsfunktion bruger den til at måle det med ??
> 
> Ikke noget, du kan bruge fra user space.

Det kan man nu sagtens "rdtsc" er ikke en priviligeret instruktion:

int main(int argc, char **argv)
{
	unsigned long low, high;
	
	asm("rdtsc" :"=a" (low), "=d" (high));
	
	print ("high: %u, low: %u\n", high, low);

}

"rdtsc" findes dog kun på Pentium eller højere (og Athlon)

Så er det bare kende cpuklokken. Fx. ved at læse /proc/cpuinfo, eller
selv at udregne det vha. et kortere vent og optælling af cpu-cykler.

> En løkke omkring en sammenligning med gettimeofday() (som er både hurtig
> og med høj præcision) er umiddelbart mit bedste bud, men stadig ikke til
> de tidsintervaller, du snakkede om. Du kan også se på
> select()/pselect(), som måske er lidt mere portable.

Det hjælper vel ikke rigtig noget med at lave gettimeofday() systemkald
når vi snakker om forsinkelser i 100nsec området. Jeg ved ikke hvad tiden
for kontekst skift er under linux præcist, men under Minix er det oppe i
omkring et 1/2 mikrosekund (900Mhz Celeron), og Linux er næppe hurtigere.

På 100ns når man ikke at udføre mange instruktioner.

Mvh Morten


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *