From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 4 04:28:06 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 75EA416A403 for ; Thu, 4 Jan 2007 04:28:06 +0000 (UTC) (envelope-from anandhkrishnan@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.237]) by mx1.freebsd.org (Postfix) with ESMTP id 3A44113C442 for ; Thu, 4 Jan 2007 04:28:06 +0000 (UTC) (envelope-from anandhkrishnan@gmail.com) Received: by wr-out-0506.google.com with SMTP id 55so2146267wri for ; Wed, 03 Jan 2007 20:28:05 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Tawe3zXF15nI5BipirKOCCh6S2Bh/UcAJxZdKDHtOfzTuFjlUUNxobcA0g2XvUrzIaqdWiuz6P+Y4K7VKtoEADeh1NhZ7gBqnIcn9O5VEywNgTwohRWD7WzXmTyD5OSothiqMBTRTQLcYf1rvvBgofgkozJudN88xke5qTXcJjE= Received: by 10.90.90.16 with SMTP id n16mr15365041agb.1167883154365; Wed, 03 Jan 2007 19:59:14 -0800 (PST) Received: by 10.90.74.4 with HTTP; Wed, 3 Jan 2007 19:59:14 -0800 (PST) Message-ID: <9bf098930701031959o3956bdfw7628cf1a5ef5b698@mail.gmail.com> Date: Thu, 4 Jan 2007 09:29:14 +0530 From: "Anand H. Krishnan" To: "John Baldwin" In-Reply-To: <200701031556.52960.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9bf098930701020242t232a1131r355c693618169441@mail.gmail.com> <200701031556.52960.jhb@freebsd.org> Cc: freebsd-hackers@freebsd.org, hackers@freebsd.org Subject: Re: Doubts with scheduler code 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: Thu, 04 Jan 2007 04:28:06 -0000 Hi, > > * First one is in the wakeup() code. After a series of calls wakeup() > > lands in maybe_preempt() and if preemption is enabled maybe_preempt() > > switches to a new thread (if a high priority thread has been made runnable). > > That means that an interrupt handler which calls wakeup() will not return > > immediately. (I'm looking @ ULE scheduler). > > > > So is there a problem when wakeup() is called from high priority (fast > interr > > upt) handlers ? > > Interrupt threads have higher priority than the threads they wakeup. For > the INTR_FAST case we run INTR_FAST handlers inside a critical section so > that if a INTR_FAST handler wakes up a thread such as the clock or serial > SWI, the preemption is deferred until after the INTR_FAST handler returns. Saw that yesterday. Thanks for the clarification... > > > * Second one is in spinlock code. Can anyone say why critical_enter is > > called from spinlock_enter() ? The only thing that critical_enter seems to > > be doing is to increment td_critnest which probably helps in finding out > > whether a thread can be pre-empted or not. But spinlock_enter() disables > > interrupts and I fail to understand how can any thread become runnable > > and get scheduled in between. > > A thread may wake up another thread while holding a spin lock. There are > numerous examples of this. Never thought about that.. > > > I've one more.. > > > > * msleep() allows a thread to change it's priority when it gets woken up and > > in many places they gets woken up with very high priority indeed. Is there > > any convincing reason as to why it should be ? > > This is something that the 4BSD scheduler has done since before FreeBSD > existed. The priority boost is intended to give higher priority to > interactive processes (since they tend to sleep on I/O a lot) versus > compute-bound processes. Thanks John and Coleman for your replies. Anand > > -- > John Baldwin >