Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Oct 2008 11:04:04 +0200
From:      Krassimir Slavchev <>
To:        Julian Elischer <>
Cc:, Sam Xia <>
Subject:   Re: 1. thread switching time? (Krassimir Slavchev)
Message-ID:  <>
In-Reply-To: <>
References:  <000001c93b0c$6195e6b0$>	<> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
Hash: SHA1

Hello Julian,

Julian Elischer wrote:
> Krassimir Slavchev wrote:
>> Also, I am able to set HZ=100000 but the thread switching time is still
>> ~1ms.
> You must be talking about the time that a thread can run before it is
> pushed out by other threads?  I know I've seem many x 10,000 context
> switches in some cases, i.e. look at very high interrupt rates
> etc. so I guess I'm not sure what you are measuring..

Okay, I have a thread with:

while(1) {
	clock_gettime(CLOCK_REALTIME, &tv);
	nanosleep(&delay, NULL);
	clock_gettime(CLOCK_REALTIME, &tv2);
	timespecsub(&tv2, &tv);

If the delay is configured to be 0 < delay < 1ms I always get ~1ms delay.
Since nanosleep() is a cancellation point this means that the scheduler
will switch to another thread.
If the delay = 0 I get ~1600ns delay.

Yes. You are right. This is "the time that a thread can run before it is
pushed out by other threads".

Is there a way to decrease this time?

> at one time the scheduling quantum was independent of Hz.
> I am not sure how true that is now..

It seems to be independent of HZ.

Best Regards

> _______________________________________________
> mailing list
> To unsubscribe, send any mail to
> ""

Version: GnuPG v1.4.7 (FreeBSD)


Want to link to this message? Use this URL: <>