From owner-freebsd-hackers Sun May 26 12: 9:50 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from ns0.seaman.net (ns0.seaman.net [168.215.64.186]) by hub.freebsd.org (Postfix) with ESMTP id 799A137B41F for ; Sun, 26 May 2002 12:09:35 -0700 (PDT) Received: from tbird.internal.seaman.net (tbird [192.168.10.12]) by ns0.seaman.net (8.12.3/8.12.3) with ESMTP id g4QJ9YYA004607 for ; Sun, 26 May 2002 14:09:34 -0500 (CDT) (envelope-from dick@seaman.org) Received: (from dick@localhost) by tbird.internal.seaman.net (8.11.6/8.11.6) id g4QJ9Yt17904 for freebsd-hackers@freebsd.org; Sun, 26 May 2002 14:09:34 -0500 Date: Sun, 26 May 2002 14:09:34 -0500 From: "Richard Seaman, Jr." To: freebsd-hackers@freebsd.org Subject: Understanding resetpriority() ? Message-ID: <20020526140934.D1813@seaman.org> Mail-Followup-To: "Richard Seaman, Jr." , freebsd-hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I don't understand the resetpriority() function in the file kern_synch.c in -current. I'm wondering if someone can help me? What I don't understand is the logic for the call(s) to maybe_resched() in resetpriority(). resetpriority() adjusts kg->kg_user_pri, but doesn't touch td->td_priority. Therefore the call(s) to maybe_resched() seems to be a no-op? Now, if the callers of resetpriority() are fiddling with td->td_priority before calling resetpriority(), then I could maybe understand this. But, in every case I can see, the caller of resetpriority() either does not change td->td_priority at all, or it adjusts if _after_ the call to resetpriority(). Therefore, it seems to me that maybe the call to maybe_resched not only is a no-op, but perhaps the call should be made later, where needed, by the callers to resetpriority()? Thanks for any help. From kern_synch.c: void resetpriority(kg) register struct ksegrp *kg; { register unsigned int newpriority; struct thread *td; mtx_lock_spin(&sched_lock); if (kg->kg_pri_class == PRI_TIMESHARE) { newpriority = PUSER + kg->kg_estcpu / INVERSE_ESTCPU_WEIGHT + NICE_WEIGHT * (kg->kg_nice - PRIO_MIN); newpriority = min(max(newpriority, PRI_MIN_TIMESHARE), PRI_MAX_TIMESHARE); kg->kg_user_pri = newpriority; } FOREACH_THREAD_IN_GROUP(kg, td) { <------ I don't understand maybe_resched(td); <------ these } mtx_unlock_spin(&sched_lock); } and earlier: void maybe_resched(struct thread *td) { mtx_assert(&sched_lock, MA_OWNED); if (td->td_priority < curthread->td_priority) curthread->td_kse->ke_flags |= KEF_NEEDRESCHED; } -- Richard Seaman, Jr. email: dick@seaman.org 5182 N. Maple Lane phone: 262-367-5450 Nashotah WI 53058 fax: 262-367-5852 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message