From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 30 21:26:37 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 EF281106564A for ; Wed, 30 Apr 2008 21:26:37 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outA.internet-mail-service.net (outa.internet-mail-service.net [216.240.47.224]) by mx1.freebsd.org (Postfix) with ESMTP id CCC9E8FC0A for ; Wed, 30 Apr 2008 21:26:37 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Wed, 30 Apr 2008 19:44:10 -0700 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id D5D762D6004; Wed, 30 Apr 2008 14:26:36 -0700 (PDT) Message-ID: <4818E40F.9070004@elischer.org> Date: Wed, 30 Apr 2008 14:26:39 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) MIME-Version: 1.0 To: "Murty, Ravi" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: maybe_preempt_in_ksegrp 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: Wed, 30 Apr 2008 21:26:38 -0000 Murty, Ravi wrote: > Hello All, > > > > Looking through the scheduler code (kern_switch.c) and two functions > that stood out were the following: > > > > 1. maybe_preempt_in_ksegrp - this function basically checks if the > thread being made runnable should preempt another thread that is part of > the same ksegrp. This makes sense. What I am having difficulty wrapping > my brain around is the fact that if all checks pass, the kernel call > mi_switch(SW_INVOL, NULL). The second parameter is NULL. This means that > it expects sched_choose to pick a thread from the ksegrp. While "I" am higher than others in the kse group, I may not be the highest thread avalable in the system. (at least that is my recollection without going to check out a 6.x tree to look back at it.. My memory is that it just placed itself on the KSEG's run queue. If it thinks that it doesn't have a chance of running it doesn't bother to even try to get scheduled, but if it thinks it might, then it asks for the scheduler to re-evaluate. > I would have > expected it to say "I am preempting curthread because I am in the same > ksegrp but higher priority, therefore switch to me".. the second > parameter would have been td? When I compare this with what happens in > mybe_preempt, the second parameter to mi_switch is the target thread > because we're preempting the curthread (any ksegrp) to run the new > thread. This makes sense. possibly. you could try it to see if it makes a difference. This code was all removed in 7.x It was never completed Why are you studying 6.x? I asked you this before but I forgot the answer :-) > 2. Why do we check the state of the kse and make sure it is > KES_THREAD. I would imagine that when this function is called, the state > is exactly KES_THREAD? What am I missing here? Paranoia and history. > > > > Thanks > > Ravi Murty > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"