Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Oct 2008 21:46:12 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
Cc:        freebsd-hackers@freebsd.org, ushasri tummala <tummala.ushasri@gmail.com>
Subject:   Re: What is the time between 2 mi_switches in freebsd.
Message-ID:  <86zlleq397.fsf@ds4.des.no>
In-Reply-To: <20081008174956.GA98121@nexus.in-nomine.org> (Jeroen Ruigrok van der Werven's message of "Wed, 8 Oct 2008 19:49:56 %2B0200")
References:  <53fa490b0810071947j23fc0f72n5360b6f174ddc96d@mail.gmail.com> <86ljwzqblx.fsf@ds4.des.no> <53fa490b0810081014k7c6c3ddfs8f43526da72d881@mail.gmail.com> <20081008174956.GA98121@nexus.in-nomine.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org> writes:
> -On [20081008 19:15], ushasri tummala (tummala.ushasri@gmail.com) wrote:
> > I just want to know how its(time between 2 mi_switch()) calculated
> > and in which variable is it stored in the code.(FreeBSD 5.2 release)
> > This is not addressed in text book.
> What Dag-Erling meant to say, and if I recall correctly, a switch() is
> highly dependent on your hardware. So the time taken for a specific
> machine can be vastly different from another machine.

No, no, no.

Assuming the question is really "what is the time between two task
switches",

A task switch can happen for one of many reasons:

 - first, and simplest, the current task has used up its quantum;

 - the current task is waiting for an external event (I/O, a mutex, a
   timeout, etc.)

 - the current task has terminated;

 - something happened to make a higher-priority task runnable;

 - ...

The closest you can get to a hard answer is if you consider only the
first of the above, in which case the answer is 1/hz second, where "hz"
is literally a kernel variable named hz.  Its default value is 1,000 on
amd64, i386, ia64 and sparc64, and 100 on all other platforms.

(actually, it's more complicated than that, because this default value
is a preprocessor macro called HZ which you can redefine in your kernel
config, and you can also set hz at boot time using the kern.hz loader
tunable)

A nice little project for someone with a lot of time on their hands
would be to make the FreeBSD kernel tickless, thus (to oversimplify)
eliminating hz.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86zlleq397.fsf>