What is the time between 2 mi_switches in freebsd.
John Baldwin
jhb at freebsd.org
Mon Oct 13 16:03:21 UTC 2008
On Wednesday 08 October 2008 03:46:12 pm Dag-Erling Smørgrav wrote:
> Jeroen Ruigrok van der Werven <asmodai at in-nomine.org> writes:
> > -On [20081008 19:15], ushasri tummala (tummala.ushasri at 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, hz isn't the quantum. sched_tick() is called 'hz' times per second,
but the scheduler is free to implement its own quantum. The default quantum
for 4BSD is actually hz / 10 for example:
static int sched_quantum; /* Roundrobin scheduling quantum in ticks. */
#define SCHED_QUANTUM (hz / 10) /* Default sched quantum */
I'm not sure what ULE's quantum is or how it is computed.
--
John Baldwin
More information about the freebsd-hackers
mailing list