[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: impact on performances of (kernel + XFREE)



On Mon, Oct 29, 2001 at 02:35:15PM +0100, Marco Fioretti wrote:
> In such a context, how much do a modern kernel and Xfree pair "impact"
> on overall performance? In other words, of 1000 CPU clock cycles, how
> many would be spent executing actual application code in the CPU, and
> how many for all the system functions, or just waiting for interrupts?

Hrm.  I'm not really too sure how you would test all of these
things---getting accurate, detailed answers to all your questions would
require some serious time spent on in-depth research.

But, for starters, you can get an approximate feel for context switching
time by writing two simple programs:

    Program 1: a simple counter.  When the program starts, it records
the system time.  It then executes an empty loop (i.e. it counts to a
very big number).  Next it again takes the system time, and subtracts
that from the original (i.e., you get the execution time or how long it
took to count to the very big number).  Output the time difference to
the screen.

    Program 2: a simple hardware timer.  This program sets a software
interrupt to go off many times per second.  The function you call when
the alarm goes off is empty.

I'm actually doing this in an embedded systems class labratory.  We
first ran program 1 at a priority greater than all other running
processes.  We did that a few times, recording the execution time.  On
"classic" Pentium 100s, it took about 5 minutes to count to a billion.

We then did the same test, but with the "annoying" program running in
the background.  The "annoying" program was run at a greater priority
than the counter.  Our annoying program was set to generate an interrupt
100 times per second (i.e. 100 Hz, the highest resolution offered on PC
hardware).

Since our alarm-driven function was empty, and knowing how many
interrupts were generated in a given time period, we can calculate a
very rough estimate of context switch time.

After that, we merged the two programs into one, and made the "annoying"
program a thread (which obviously resulted in shorter context-switching
times).

I can send you the code if you like.

Matt

-- 
Matt Garman, garman@uiuc.edu
I find it truly amazing that social progress exists in light of the vast
number of people who would rather persue shallow, unconsequential
personal goals than try to contribute to civilization.



Reply to: