Re: context switch time

Roland Nagtegaal (roland@powerstar.nl)
Sat, 18 Apr 1998 14:33:21 +0200


Larry McVoy wrote:
>
> : Could someone knowledged enough please tell me approximately how many
> : cycles takes a process context switch on a pentium in Linux?
>
> It depends. If all you want is the 2 process flipping back and forth
> number, it is ~5 usecs on a K6@233Mhz and ~9 usecs on P5@120Mhz.
> The numbers go up dramatically as the size of the process goes up.
> By orders of magnitude. Think about it: if all I am dong is context
> switching then most of what I need is in the L2 cache tagged by context id
> and I don't go to memory at all. So it becomes a pure CPU speed issue.
> But if I'm touching data in each context, then I am throwing the other
> guy's data out of the cache and he gets stalled when he sarts up again.
>
> Unfortunately, the latter is far more common than the former.

I have a question about this:
How high can I put HZ (in /usr/src/linux/include/asm-i386/param.h)
before
I get a (significant) slow-down because of:

- cache misses
By this I mean that the current process might heavily use the
cache, for instance a multimedia program or game. Then the
next process gets the processor and cache, so the former will
probably have a cache miss. If HZ is sufficiently low, this
problem will not be so bad. But how can I find out what might
be the optimal value, of course depending on your processor
speed and vendor (AMD,Intel etc.)? I didn't measure any
slowdown when putting HZ to 1024 on a K6 200. The computer did
get a lot more responsive.
Some things break though: top measured 978% processor usage.
- context switch overhead
How many cycles does Linux take to do a task switch?
And what about threads?
Is it competitive compared to per example NT 4.0?

----------------------------------------------------------------------
UNIX isn't dead, it just smells funny...
Run Linux! Keep The Net Free!
----------------------------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu