Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2002 23:57:33 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        John Baldwin <jhb@FreeBSD.ORG>, arch@FreeBSD.ORG, Alfred Perlstein <bright@mu.org>
Subject:   Re: Process/thread states.
Message-ID:  <Pine.BSF.4.21.0209032347000.26122-100000@InterJet.elischer.org>
In-Reply-To: <20020904163927.N385-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help


On Wed, 4 Sep 2002, Bruce Evans wrote:

> On Tue, 3 Sep 2002, Julian Elischer wrote:
> 
> > On Tue, 3 Sep 2002, John Baldwin wrote:
> >
> > > ... (I don't
> > > see why just using == to check a thread state is all that hard).
> >
> > because it in some cases actually becomes: (due to the fact thst you
> > can be on the sleep queue AND teh run queue)
> > #define TD_ON_RUNQ(td) (((td)->td_state & TD_BASE_MASK) == TD_ST_RUNQ)
> > as you have to separate out the sleep queue bit.
> > ...
> > Do you really want to type that sort of test everywhere?
> > By making it a macro we can keep the implementation of this state
> > hidden. e.g if we move the RUNQ part of the state to td_flags
> > to make it independently testable, the rest of the code doesn;t have to
> > know how we optimised this. (we are discussing this exact change now).
> > similarly for swapped.. or other states.
> 
> Just don't forget to change it back to a simple test once you have debugged
> and optimized it :-).  One virtue of inline code is that it inhibits expansion
> of huge macros to huger ones.

that is true, but I want to be able to make the Macros as fast and simple
as possible. If I have to edit 300 places to rearange bits to achieve this
it gets prohibative. If it's a macro that just says what I am trying to
achieve, and how that is achieved is hidden, then I can rejig the macro to
achieve that in the most efficient manner as different ideas abotu
threading get tried and rejected or accepted...

Do you mean edit it again and remove all the macros later?
There is a certain readbility that comes with a concise macro name
that is not present (from the point of view of the lay reader)
in the more crude direct tests.

If (TD_ON_SLEEPQ(td) && TD_IS_RUNNING(td))
is presently expressed as:

if ((td->td_wchan != 0) && td->td_state == TDS_RUNNING)

I know which of those two I'd rather see if I was a new developer trying
to work out what the heck is going on..

A great increase in readability could be made by simply adding the macro
TD_ON_SLEEPQ(td), but if we have that then we might as well have 
the rest of the macros as well.


 
> > Bruce
> 
> 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0209032347000.26122-100000>