From owner-freebsd-current@FreeBSD.ORG Wed Feb 27 02:26:47 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE8A81065672 for ; Wed, 27 Feb 2008 02:26:47 +0000 (UTC) (envelope-from ravi.murty@intel.com) Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by mx1.freebsd.org (Postfix) with ESMTP id 9DD9313C459 for ; Wed, 27 Feb 2008 02:26:47 +0000 (UTC) (envelope-from ravi.murty@intel.com) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 26 Feb 2008 18:16:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.25,410,1199692800"; d="scan'208,217";a="383927897" Received: from orsmsx334.amr.corp.intel.com (HELO orsmsx334.jf.intel.com) ([10.22.226.45]) by azsmga001.ch.intel.com with ESMTP; 26 Feb 2008 18:04:50 -0800 Received: from orsmsx416.amr.corp.intel.com ([10.22.226.46]) by orsmsx334.jf.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 26 Feb 2008 18:04:49 -0800 Content-class: urn:content-classes:message MIME-Version: 1.0 X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Tue, 26 Feb 2008 18:04:45 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Scheduler questions thread-index: Ach45R+az9oAiVuZRJapk0FfdCrTBg== From: "Murty, Ravi" To: X-OriginalArrivalTime: 27 Feb 2008 02:04:49.0855 (UTC) FILETIME=[224FACF0:01C878E5] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Scheduler questions X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2008 02:26:47 -0000 Hello Everyone, =20 I've been looking at the scheduler to understand some finer details and have a couple of questions I am hoping someone can answer pretty easily. =20 1. critnest: It appears that the whole point of critical_enter and critical_exit is to prevent preemption in the kernel by using these functions. I can see this being useful when kernel preemption is defined, but I can't seem to figure out why this would matter if kernel preemption is not defined. I can think of a case - e.g. thread enters kernel and is in critical section, timer interrupt fires and tries to preempt thread because it's time quantum expired. But I can't seem to find how this works. Also, why would critnest be equal to 2 or more? 2. Again, time quantum related question. When the scheduler (e.g. ULE) decides (in sched_clock) that it's time to switch a thread out because its time slice is 0, it sets the NEEDRESCHED flag and expects the ast() routine (as part of the return from the timer interrupt handler) to call mi_switch(). Why not call mi_switch right there in sched_clock()? =20 Thanks Ravi Murty