From owner-cvs-src@FreeBSD.ORG Sat Mar 17 20:16:54 2007 Return-Path: X-Original-To: cvs-src@freebsd.org Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6516016A404; Sat, 17 Mar 2007 20:16:54 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from webaccess-cl.virtdom.com (webaccess-cl.virtdom.com [216.240.101.25]) by mx1.freebsd.org (Postfix) with ESMTP id 2ACA113C45E; Sat, 17 Mar 2007 20:16:54 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from [10.0.0.1] (63-226-247-187.tukw.qwest.net [63.226.247.187]) (authenticated bits=0) by webaccess-cl.virtdom.com (8.13.6/8.13.6) with ESMTP id l2HKGohi095295 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Sat, 17 Mar 2007 15:16:51 -0500 (EST) (envelope-from jroberson@chesapeake.net) Date: Sat, 17 Mar 2007 12:16:41 -0800 (PST) From: Jeff Roberson X-X-Sender: jroberson@10.0.0.1 To: Max Laier In-Reply-To: <200703172100.13218.max@love2party.net> Message-ID: <20070317121427.H560@10.0.0.1> References: <200703171813.l2HIDXWI008212@repoman.freebsd.org> <20070317110821.I560@10.0.0.1> <200703172100.13218.max@love2party.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: cvs-src@freebsd.org, Jeff Roberson , src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/kern sched_ule.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Mar 2007 20:16:54 -0000 On Sat, 17 Mar 2007, Max Laier wrote: > On Saturday 17 March 2007 20:09, Jeff Roberson wrote: >> Any language lawyers care to comment on this? > > I find this strange. According to the spec "(Decrementing is equivalent > to subtracting 1.)", but "pri = --pri % RQ_NQS;" will behave like you > expect, while "pri = (pri - 1) % RQ_NQS;" clearly didn't. I noticed this as well. When you do --pri, pri is promoted to int for the math and then demoted back to char wich truncates the value. Subsequently this value is used in the % operation, which gives the expected results. When you do pri - 1 the intermediate result is promoted to a signed int which doesn't yield the result you'd like when you mod with 64. Jeff > >> On Sat, 17 Mar 2007, Jeff Roberson wrote: >>> jeff 2007-03-17 18:13:33 UTC >>> >>> FreeBSD src repository >>> >>> Modified files: >>> sys/kern sched_ule.c >>> Log: >>> - Cast the intermediate value in priority computtion back down to >>> unsigned char. Weirdly, casting the 1 constant to u_char still >>> produces a signed integer result that is then used in the % >>> computation. This avoids that mess all together and causes a 0 pri >>> to turn into 255 % 64 as we expect. >>> >>> Reported by: kkenn (about 4 times, thanks) >>> >>> Revision Changes Path >>> 1.190 +1 -1 src/sys/kern/sched_ule.c > > -- > /"\ Best regards, | mlaier@freebsd.org > \ / Max Laier | ICQ #67774661 > X http://pf4freebsd.love2party.net/ | mlaier@EFnet > / \ ASCII Ribbon Campaign | Against HTML Mail and News >