[ros-kernel] [PATCH] IoAdjustPagingPathCount

Travis Snoozy ai2097 at yahoo.com
Wed Jun 9 17:52:54 CEST 2004


On Wed, 2004-06-09 at 16:20, Eric Kohl wrote:
> "Alex Ionescu" <ionucu at videotron.ca> wrote:
> 
> 
> > Travis,
> > 
> > I had mentioned in the channel that AFAIK it was actually a Macro... I'll
> > try to find the definition of it and tell you if it's right.
> 
> IoAdjustPagingPathCount is a macro in the Win2k DDK.
> 
> 
> Regards,
> Eric

All right... buuuut, we need to make sure that the boolean gets stored
in a safe place while we perform the operation. The present
implementation we have (in winddk.h) is -not- appropriately atomic.

I propose using this:

inline static
VOID
IoAdjustPagingPathCount(
    IN PLONG  Count,
    IN BOOLEAN  Increment)
{
    if(!Count)
        {return;}

    if(Increment)
    {
        InterlockedIncrement(Count);
    }
    else
    {
        InterlockedDecrement(Count);
    }
}

Benefits:
    (1) Type checking
    (2) Safe storage of all the variables such that the operation is
fully shielded/atomic

And it's macro-like:
    (3) Inlined every use
    (4) Declaring static means that we won't have any "multiple
definition" issues when we link

And it won't break code:
    (5) 3rd party & old bins have the old macro already compiled into
them
    (6) Legacy programs won't notice the difference on recompile, unless
        (6a) The call is made with bad types, in which case it should be
fixed anyway. (see #1 :)

So... that's my 2 cents.

-- Travis





More information about the Ros-kernel mailing list