DragonFly BSD
DragonFly kernel List (threaded) for 2005-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: kern_synch.c


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 29 Jan 2005 11:52:26 -0800 (PST)

:Hi, I just started poking around the kernel code, so I don't know if my
:question is even relevant.  In /usr/src/kern/kern_synch.c on line 736
:there is a function called resetpriority().  On line 739 of the same file
:in the same function there is an variable called interactive, which is an
:int.  On line 773, interactive is used in the following way:
:
:        interactive = p->p_interactive / 10;
:        newpriority += interactive;
:
:Since interactive is only used on lines 773 and 774 in resetpriority() and
:since it is local to the function, why not replace these two lines with:
:
:	newpriority += (p->p_interactive / 10);
:
:and do away with the variable interactive entirely?
:...
:Thanks,
:-Zera Holladay

    This is a case where the code was written to be more readable and
    explicit.  You don't really have to compact it all into a single
    line, the C compiler will probably generate the same code either
    way and optimize out the intermediate variable (not that we really
    care from a performance standpoint in this particular piece of 
    code since just doing the divide is ten times as expensive as 
    anything else).

					-Matt
					Matthew Dillon 
					<dillon@xxxxxxxxxxxxx>




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]