From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 13 16:03:21 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88CAA10656C0 for ; Mon, 13 Oct 2008 16:03:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id BE9038FC0C for ; Mon, 13 Oct 2008 16:03:20 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m9DG2cwB011912; Mon, 13 Oct 2008 12:03:08 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Mon, 13 Oct 2008 10:51:06 -0400 User-Agent: KMail/1.9.7 References: <53fa490b0810071947j23fc0f72n5360b6f174ddc96d@mail.gmail.com> <20081008174956.GA98121@nexus.in-nomine.org> <86zlleq397.fsf@ds4.des.no> In-Reply-To: <86zlleq397.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200810131051.07174.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 13 Oct 2008 12:03:11 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8417/Mon Oct 13 03:34:29 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Dag-Erling =?utf-8?q?Sm=C3=B8rgrav?= , ushasri tummala , Jeroen Ruigrok van der Werven Subject: Re: What is the time between 2 mi_switches in freebsd. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2008 16:03:21 -0000 On Wednesday 08 October 2008 03:46:12 pm Dag-Erling Sm=C3=B8rgrav wrote: > Jeroen Ruigrok van der Werven 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. >=20 > No, no, no. >=20 > Assuming the question is really "what is the time between two task > switches", >=20 > A task switch can happen for one of many reasons: >=20 > - first, and simplest, the current task has used up its quantum; >=20 > - the current task is waiting for an external event (I/O, a mutex, a > timeout, etc.) >=20 > - the current task has terminated; >=20 > - something happened to make a higher-priority task runnable; >=20 > - ... >=20 > 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 seco= nd,=20 but the scheduler is free to implement its own quantum. The default quantu= m=20 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. =2D-=20 John Baldwin