RE: [NTDEV] Queue Management ...


When I saw this I assumed that this was just implemented for a particular
task and it didn’t involve operating on the middle of the list. Nobody was
given the task of creating a “full” set of list operators.

Are we having fun yet?

Michael S. Jackson

-----Original Message-----
From: Gary Little []
Sent: Tuesday, July 03, 2001 10:50 AM
To: NT Developers Interest List
Subject: [ntdev] [NTDEV] Queue Management …

In prior versions of the DDK, there has never been an interlocked mid-queue
management function. You can insert on the tail or head using
ExInterlockedInsertTail/HeadList, or remove from the tail or head using
ExInterlockedRemoveTail/HeadList. However, the only way to remove things
from the middle of a queue was RemoveEntryList, which is but one of those
deadly macros.

Why has there never been an ExInterlockedRemoveEntryList to permit an
orthogonal, and atomic, management of doubly linked queues? For my own
purposes I have written one using a combination of inline assembly to clear
and restore the interrupt mask “pushfd/cli/…popfd”, and “lock bts” to
acquire a spin lock, and RemoveEntryList to manage the queue. However, it
would be nice if this were down in the HAL, or kernel, to provide some
platform independence and total synchronized queue management.

I posted this in the DDK Beta newsgroup for XP and received the following
reply from a Jamie Hunter at Microsoft:

“Disabling and enabling the interrupts on NT code base is bad! For starters,
it will not be mutually exclusive in multi-processor systems, so the
behavior you expect isn’t what you get, and this kind of thing makes drivers
unstable on multi-proc when working fine on single-proc. ExInterlockedXXX
APIs use processor instructions that are guaranteed to be exclusive on a
multi-processor system. Depending on what you need to be exclusive with, you
should use spin-locks or KeSynchronizeExecution.”

The fact that the ExInterlockedXXX functions use “pushfd/cli/…popfd”, and
“lock bts” to acquire a spin lock tends to make the remainder of Jamie’s
argument moot. I simply think they need to add one more. Spin locks will not
solve my particular problem since the queue I am managing must be accessed
at IRQLs above DISPATCH_LEVEL. I cannot use KeSynchronizeExecution because
my design is such that queue management is carried out in a layer where I do
not have access to the interrupt object. Without
ExInterlockedRemoveEntryList, management of that queue between
DISPATCH_LEVEL and DIRQL becomes a real problem.

My question is, since interlocked functions exist for Insert/Remove
head/tail of a list, why not mid-queue management as well?

Gary G. Little
Staff Engineer
Broadband Storage, Inc.

You are currently subscribed to ntdev as:
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)

You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)