[lkml]   [1999]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Measured overhead of timer interrupts
> any change to change your test to run with P5/K2-2 ?

Due to "popular" demand, I've updated the test to run on older x86
processors. Must be a P5 or later equivalent.

I still haven't measured a 1024Hz kernel yet -- any takers?

-- Jamie

/* Measure overhead taken by kernel from a running process.
x86 with rdtsc required. Version 2.

Copyright (C) 1999 Jamie Lokier.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

#define LOOP 10000000 /* You may have to reduce this to avoid overflow. */

/* Define CLI to disable interrupts. sync() your disks first! */
/* Define SCHED to run at high priority. sync() your disks first! */

#include <stdio.h>
#include <sys/io.h>
#include <sched.h>
int main ()
unsigned int dummy, low, high, total;

#ifdef SCHED
struct sched_param param;
memset (&param, 0, sizeof (param));
param.sched_priority = sched_get_priority_max (SCHED_FIFO);
sched_setscheduler (getpid (), SCHED_FIFO, &param);

#ifdef CLI
iopl (3); __asm__ volatile ("cli");

__asm__ volatile ("
pushl %%ebp
0: movl %%eax,%%ebp
subl %%eax,%%ebp\n"
#ifdef CMOV
" cmpl %%ebp,%%esi
cmovbl %%ebp,%%esi
cmpl %%ebp,%%edi
cmoval %%ebp,%%edi
incl %%ecx
cmovel %%ecx,%%esi
cmovel %%ebx,%%edi
cmovel %%eax,%%ebx\n"
#else /* not CMOV */
" xorl %%edx,%%edx
subl %%ebp,%%esi
sbbl $0,%%edx
andl %%esi,%%edx
addl %%ebp,%%esi
subl %%edx,%%esi
movl $-1,%%edx
subl %%ebp,%%edi
adcl $0,%%edx
andl %%edi,%%edx
addl %%ebp,%%edi
subl %%edx,%%edi
movl $-1,%%edx
addl $1,%%ecx
adcl $0,%%edx
andl %%edx,%%esi
notl %%edx
orl %%edx,%%edi
orl %%edx,%%ebx
notl %%edx
orl %%eax,%%edx
andl %%edx,%%ebx\n"
#endif /* not CMOV */
" cmpl %4,%%ecx
jnz 0b
subl %%ebx,%%eax
popl %%ebp"
: "=c" (dummy), "=S" (low), "=D" (high), "=a" (total)
: "i" (LOOP), "c" (-50), "b" (0xffffffff)
: "ebx", "edx");

#ifdef CLI
__asm__ volatile ("sti"); iopl (0);

low = -low;
high = -high;
printf ("low: %08x, high %08x, total %08x, lost %08x\n"
"Percentage cycles lost: %0.6f%%\n",
low, high, total, (total - low * LOOP),
(total - low * (double) LOOP) / total * 100);

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

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