From owner-freebsd-arch Tue Mar 5 10: 0:39 2002 Delivered-To: freebsd-arch@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id DF00937B41A; Tue, 5 Mar 2002 10:00:25 -0800 (PST) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020305180025.TMXZ1214.rwcrmhc54.attbi.com@InterJet.elischer.org>; Tue, 5 Mar 2002 18:00:25 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id JAA31641; Tue, 5 Mar 2002 09:47:19 -0800 (PST) Date: Tue, 5 Mar 2002 09:47:18 -0800 (PST) From: Julian Elischer To: Poul-Henning Kamp Cc: arch@FreeBSD.ORG Subject: Re: kernel process priority question... In-Reply-To: <20020305223033.M4715-100000@gamplex.bde.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The person to ask is jhb, but I think that the first option is closest. td_base_pri is the base kernel priority that the process has WITHOUT PRIORITY INHERRITANCE. This is what is increased (or should be) when you specify a priority in msleep, and it wakes up. The instant priority is td->td_priority. This is what the priority is right now, including priority inheritance from mutexes wanted by others. When you go back to userland yuor priority will be reset back to kg->kg_user_pri, which is common for all thread in the scheduling group. If you are changing td_base_pri, you may need to change td_priority as well if you want it to have any effect. (I need to look at msleep to see if this is done right) td->td_priority = min(td->td_base_pri, td->td_priority); i.e. if the new base pri is more (lower than) the current priority, then boost the current priority too. On Tue, 5 Mar 2002, Bruce Evans wrote: > On Mon, 4 Mar 2002, Poul-Henning Kamp wrote: > > > What is the correct way to set a priority on a kernel thread ? > > > > Is it legal to simply set the value like this: > > > > curthread->td_base_pri = PRIBIO; > > > > Or should the detour around the rtprio stuff be used: > > > > struct rtprio rtp; > > > > rtp.prio = RTP_PRIO_MAX; > > rtp.type = RTP_PRIO_IDLE; > > mtx_lock_spin(&sched_lock); > > rtp_to_pri(&rtp, td->td_ksegrp); > > mtx_unlock_spin(&sched_lock); > > Neither. > > The rtprio stuff should be just compatibility cruft to support the > rtprio(2) mistake (extending {get,set}priority(2) would have been a > smaller mistake, but even these were obsoleted by the POSIX.1-1993 > about a year before rtprio(2) was committed). > > When setting priority fields directly, there are 4 of them in places > that keep being moved by KSE changes, and the setting may need locking, > so a function to hide the details would be useful. rtp_to_prio() is > not that function. > > Bruce > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-arch" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message