Subject: Context switch Tick

How fast does the kernel switches contexts, and does it dependent on type
and speed of cpu?
Where/how can I find current system tick rate for the Linux kernel context
switch?


Subject: RE: Context switch Tick

Okay, vmstat show me the cs according to current load, what is the Maximum
tick rate?
A process requests a 1 microseconds sleep, or even 500 nanoseconds, how long
does it actually sleep, that is why I need to know max tick rate for context
switch for a given CPU.

-----Original Message-----
From: Mathieu Segaud [mailto:[email protected]]
Sent: Wednesday, June 02, 2004 3:52 PM
To: Garboua Nahil Y Contr WRALC/MASFE
Subject: Re: Context switch Tick

Garboua Nahil Y Contr WRALC/MASFE <[email protected]> writes:

> How fast does the kernel switches contexts, and does it dependent on type
> and speed of cpu?
> Where/how can I find current system tick rate for the Linux kernel
> context switch?

The context switch tick rate depends on many things:
- any time an interrupt is triggered, there is a ctx switch,
- schedule() performs a context switch if it finds a suitable process,
- schedule() is called on every blocking io that a process calls for,

so the rate is quite changing ;)
if you want to know the current ctx switch rate, use vmstat

vmstat 1 will gives a line per second on system info:
process statistics, io stats, memory stats, and cpu stats

the one you want is denoted "cs"

--
Mathieu Segaud

> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-kernel" in the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2004-06-02 20:52:35

by Richard B. Johnson

[permalink] [raw]
Subject: RE: Context switch Tick

On Wed, 2 Jun 2004, Garboua Nahil Y Contr WRALC/MASFE wrote:

> Okay, vmstat show me the cs according to current load, what is the Maximum
> tick rate?
> A process requests a 1 microseconds sleep, or even 500 nanoseconds, how long
> does it actually sleep, that is why I need to know max tick rate for context
> switch for a given CPU.

Can't you just measure it?

Script started on Wed Jun 2 16:48:51 2004
# ./tester
Testing CPU Speed (once at start of program)
CPU speed = 2803766848 Hz
Cycles to make the two function calls = 88
It took 55625156 cpu cycles or 19839.437091 microseconds.
# exit
Script done on Wed Jun 2 16:48:57 2004

That was for a usleep(1). Source attached.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.


Attachments:
context.tar.gz (973.00 B)