opaque slist?

Hi,
I need to iterate through an SLIST. There aren’t any
functions to do so. Can I access the SLIST datamembers
and move from one node to the next manually? Is this
safe?

Rajeev


Everything you always wanted to know about cars and bikes,now
at: http://in.autos.yahoo.com/cricket/tracker.html

Hi, Rajeev,

Iterating throught the SList elements is not safe. SList manipulations are performed only at the
queue head, and always interlocked (an atomic update across all processors). There’s no way to lock
accesses on arbitrary list elements against the manipulations at the head.

The only way to safely do what you want with an SList is to pop every entry using
ExInterlockedPopEntrySList, save to a private list, and then push back to the list using
ExInterlockedPushEntrySList when done. This would have abysmal performance implications in a common
code path, but might be acceptable for an infrequent code path, like a rare error path.

Tom Stonecypher
iStreamConsulting.com

“Rajeev Rao” wrote in message news:xxxxx@ntdev…
>
> Hi,
> I need to iterate through an SLIST. There aren’t any
> functions to do so. Can I access the SLIST datamembers
> and move from one node to the next manually? Is this
> safe?
>
> Rajeev
>
>
> ________________________________________________________________________
> Everything you always wanted to know about cars and bikes,now
> at: http://in.autos.yahoo.com/cricket/tracker.html
>
>

A simpler implementation would be to use a doubly linked list —
LIST_ENTRY.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Tom Stonecypher” wrote in message
news:xxxxx@ntdev…
>
> Hi, Rajeev,
>
> Iterating throught the SList elements is not safe. SList manipulations
are performed only at the
> queue head, and always interlocked (an atomic update across all
processors). There’s no way to lock
> accesses on arbitrary list elements against the manipulations at the head.
>
> The only way to safely do what you want with an SList is to pop every
entry using
> ExInterlockedPopEntrySList, save to a private list, and then push back to
the list using
> ExInterlockedPushEntrySList when done. This would have abysmal
performance implications in a common
> code path, but might be acceptable for an infrequent code path, like a
rare error path.
>
> Tom Stonecypher
> iStreamConsulting.com
>
> “Rajeev Rao” wrote in message news:xxxxx@ntdev…
> >
> > Hi,
> > I need to iterate through an SLIST. There aren’t any
> > functions to do so. Can I access the SLIST datamembers
> > and move from one node to the next manually? Is this
> > safe?
> >
> > Rajeev
> >
> >
> > ________________________________________________________________________
> > Everything you always wanted to know about cars and bikes,now
> > at: http://in.autos.yahoo.com/cricket/tracker.html
> >
> >
>
>
>
>

BTW, this is only an issue now with the new _WIN2K_COMPAT_SLIST_USAGE flag
in the build. As far as I understand it, the list’s spinlock was always
used in the past, but with this new flag ExInterlockedPush/PopEntrySList are
mapped to InterlockedPush/PopEntrySlist, and thus no spinlocks are used.


Bill McKenzie

“Tom Stonecypher” wrote in message
news:xxxxx@ntdev…
>
> Hi, Rajeev,
>
> Iterating throught the SList elements is not safe. SList manipulations
are performed only at the
> queue head, and always interlocked (an atomic update across all
processors). There’s no way to lock
> accesses on arbitrary list elements against the manipulations at the head.
>
> The only way to safely do what you want with an SList is to pop every
entry using
> ExInterlockedPopEntrySList, save to a private list, and then push back to
the list using
> ExInterlockedPushEntrySList when done. This would have abysmal
performance implications in a common
> code path, but might be acceptable for an infrequent code path, like a
rare error path.
>
> Tom Stonecypher
> iStreamConsulting.com
>
> “Rajeev Rao” wrote in message news:xxxxx@ntdev…
> >
> > Hi,
> > I need to iterate through an SLIST. There aren’t any
> > functions to do so. Can I access the SLIST datamembers
> > and move from one node to the next manually? Is this
> > safe?
> >
> > Rajeev
> >
> >
> > ________________________________________________________________________
> > Everything you always wanted to know about cars and bikes,now
> > at: http://in.autos.yahoo.com/cricket/tracker.html
> >
> >
>
>
>
>

I should have said _WIN2K_COMPAT_SLIST_USAGE not in the build.


Bill McKenzie

“Bill McKenzie” wrote in message
news:xxxxx@ntdev…
>
> BTW, this is only an issue now with the new _WIN2K_COMPAT_SLIST_USAGE flag
> in the build. As far as I understand it, the list’s spinlock was always
> used in the past, but with this new flag ExInterlockedPush/PopEntrySList
are
> mapped to InterlockedPush/PopEntrySlist, and thus no spinlocks are used.
>
> –
> Bill McKenzie
>
>
>
> “Tom Stonecypher” wrote in message
> news:xxxxx@ntdev…
> >
> > Hi, Rajeev,
> >
> > Iterating throught the SList elements is not safe. SList manipulations
> are performed only at the
> > queue head, and always interlocked (an atomic update across all
> processors). There’s no way to lock
> > accesses on arbitrary list elements against the manipulations at the
head.
> >
> > The only way to safely do what you want with an SList is to pop every
> entry using
> > ExInterlockedPopEntrySList, save to a private list, and then push back
to
> the list using
> > ExInterlockedPushEntrySList when done. This would have abysmal
> performance implications in a common
> > code path, but might be acceptable for an infrequent code path, like a
> rare error path.
> >
> > Tom Stonecypher
> > iStreamConsulting.com
> >
> > “Rajeev Rao” wrote in message news:xxxxx@ntdev…
> > >
> > > Hi,
> > > I need to iterate through an SLIST. There aren’t any
> > > functions to do so. Can I access the SLIST datamembers
> > > and move from one node to the next manually? Is this
> > > safe?
> > >
> > > Rajeev
> > >
> > >
> > >
________________________________________________________________________
> > > Everything you always wanted to know about cars and bikes,now
> > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > >
> > >
> >
> >
> >
> >
>
>
>
>

Undoubtedly a number of different solutions can be imagined if no SList is used. I was referring to
a method for handling the SList case, assuming it is a given that an SList must be used. I don’t
like the method I outlined, but it is the only answer I know to the original question, “is there a
safe way of traversing an SList”.

regards

Tom Stonecypher
iStreamConsulting.com

“Gary G. Little” wrote in message news:xxxxx@ntdev…
>
> A simpler implementation would be to use a doubly linked list —
> LIST_ENTRY.
>
> –
> Gary G. Little
> xxxxx@broadstor.com
> xxxxx@inland.net
>
> “Tom Stonecypher” wrote in message
> news:xxxxx@ntdev…
> >
> > Hi, Rajeev,
> >
> > Iterating throught the SList elements is not safe. SList manipulations
> are performed only at the
> > queue head, and always interlocked (an atomic update across all
> processors). There’s no way to lock
> > accesses on arbitrary list elements against the manipulations at the head.
> >
> > The only way to safely do what you want with an SList is to pop every
> entry using
> > ExInterlockedPopEntrySList, save to a private list, and then push back to
> the list using
> > ExInterlockedPushEntrySList when done. This would have abysmal
> performance implications in a common
> > code path, but might be acceptable for an infrequent code path, like a
> rare error path.
> >
> > Tom Stonecypher
> > iStreamConsulting.com
> >
> > “Rajeev Rao” wrote in message news:xxxxx@ntdev…
> > >
> > > Hi,
> > > I need to iterate through an SLIST. There aren’t any
> > > functions to do so. Can I access the SLIST datamembers
> > > and move from one node to the next manually? Is this
> > > safe?
> > >
> > > Rajeev
> > >
> > >
> > > ________________________________________________________________________
> > > Everything you always wanted to know about cars and bikes,now
> > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > >
> > >
> >
> >
> >
> >
>
>
>
>

Yeah there are some lovely locations, such as REQUEST_ALLOCATE_ADDRESS_RANGE
using the incorrectly named fifo list of MDls, which is really a lifo list
of MDLs, where you are forced to use this method. Microsoft and others
need to be VERY careful where they use SLISTS!!


Bill McKenzie

“Tom Stonecypher” wrote in message
news:xxxxx@ntdev…
>
> Undoubtedly a number of different solutions can be imagined if no SList is
used. I was referring to
> a method for handling the SList case, assuming it is a given that an SList
must be used. I don’t
> like the method I outlined, but it is the only answer I know to the
original question, “is there a
> safe way of traversing an SList”.
>
> regards
>
> Tom Stonecypher
> iStreamConsulting.com
>
> “Gary G. Little” wrote in message
news:xxxxx@ntdev…
> >
> > A simpler implementation would be to use a doubly linked list —
> > LIST_ENTRY.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > “Tom Stonecypher” wrote in message
> > news:xxxxx@ntdev…
> > >
> > > Hi, Rajeev,
> > >
> > > Iterating throught the SList elements is not safe. SList
manipulations
> > are performed only at the
> > > queue head, and always interlocked (an atomic update across all
> > processors). There’s no way to lock
> > > accesses on arbitrary list elements against the manipulations at the
head.
> > >
> > > The only way to safely do what you want with an SList is to pop every
> > entry using
> > > ExInterlockedPopEntrySList, save to a private list, and then push back
to
> > the list using
> > > ExInterlockedPushEntrySList when done. This would have abysmal
> > performance implications in a common
> > > code path, but might be acceptable for an infrequent code path, like a
> > rare error path.
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > “Rajeev Rao” wrote in message
news:xxxxx@ntdev…
> > > >
> > > > Hi,
> > > > I need to iterate through an SLIST. There aren’t any
> > > > functions to do so. Can I access the SLIST datamembers
> > > > and move from one node to the next manually? Is this
> > > > safe?
> > > >
> > > > Rajeev
> > > >
> > > >
> > > >
________________________________________________________________________
> > > > Everything you always wanted to know about cars and bikes,now
> > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>

Tom,

But then are you not simply “kicking against the pricks”? or “spitting into
the wind”? The ability to traverse an SLIST does not exist in the DDK. So
either you have to invent it, or use an existing methodology that has been
blessed by MS.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Tom Stonecypher” wrote in message
news:xxxxx@ntdev…
>
> Undoubtedly a number of different solutions can be imagined if no SList is
used. I was referring to
> a method for handling the SList case, assuming it is a given that an SList
must be used. I don’t
> like the method I outlined, but it is the only answer I know to the
original question, “is there a
> safe way of traversing an SList”.
>
> regards
>
> Tom Stonecypher
> iStreamConsulting.com
>
> “Gary G. Little” wrote in message
news:xxxxx@ntdev…
> >
> > A simpler implementation would be to use a doubly linked list —
> > LIST_ENTRY.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > “Tom Stonecypher” wrote in message
> > news:xxxxx@ntdev…
> > >
> > > Hi, Rajeev,
> > >
> > > Iterating throught the SList elements is not safe. SList
manipulations
> > are performed only at the
> > > queue head, and always interlocked (an atomic update across all
> > processors). There’s no way to lock
> > > accesses on arbitrary list elements against the manipulations at the
head.
> > >
> > > The only way to safely do what you want with an SList is to pop every
> > entry using
> > > ExInterlockedPopEntrySList, save to a private list, and then push back
to
> > the list using
> > > ExInterlockedPushEntrySList when done. This would have abysmal
> > performance implications in a common
> > > code path, but might be acceptable for an infrequent code path, like a
> > rare error path.
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > “Rajeev Rao” wrote in message
news:xxxxx@ntdev…
> > > >
> > > > Hi,
> > > > I need to iterate through an SLIST. There aren’t any
> > > > functions to do so. Can I access the SLIST datamembers
> > > > and move from one node to the next manually? Is this
> > > > safe?
> > > >
> > > > Rajeev
> > > >
> > > >
> > > >
________________________________________________________________________
> > > > Everything you always wanted to know about cars and bikes,now
> > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>

I guess you need to define the granularity of your lock. For example, in
some of my drivers, I have a list that keeps track of some things (i.e.
file objects, disk sectors, etc…).

I use a spinlock to protect the entire list. All list access functions
are protected. So, on a query, I first acquire the spinlock and then do
my operation and release the spinlock.

If you have a reader/writer model, you can use an ERESOURCE to protect
the list. This will allow multiple readers and a single writer; plus
ERESOURCE promotions and demotions.

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bill McKenzie
Sent: Wednesday, May 22, 2002 2:20 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

Yeah there are some lovely locations, such as
REQUEST_ALLOCATE_ADDRESS_RANGE
using the incorrectly named fifo list of MDls, which is really a lifo
list
of MDLs, where you are forced to use this method. Microsoft and others
need to be VERY careful where they use SLISTS!!


Bill McKenzie

“Tom Stonecypher” wrote in message
news:xxxxx@ntdev…
>
> Undoubtedly a number of different solutions can be imagined if no
SList is
used. I was referring to
> a method for handling the SList case, assuming it is a given that an
SList
must be used. I don’t
> like the method I outlined, but it is the only answer I know to the
original question, “is there a
> safe way of traversing an SList”.
>
> regards
>
> Tom Stonecypher
> iStreamConsulting.com
>
> “Gary G. Little” wrote in message
news:xxxxx@ntdev…
> >
> > A simpler implementation would be to use a doubly linked list —
> > LIST_ENTRY.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > “Tom Stonecypher” wrote in message
> > news:xxxxx@ntdev…
> > >
> > > Hi, Rajeev,
> > >
> > > Iterating throught the SList elements is not safe. SList
manipulations
> > are performed only at the
> > > queue head, and always interlocked (an atomic update across all
> > processors). There’s no way to lock
> > > accesses on arbitrary list elements against the manipulations at
the
head.
> > >
> > > The only way to safely do what you want with an SList is to pop
every
> > entry using
> > > ExInterlockedPopEntrySList, save to a private list, and then push
back
to
> > the list using
> > > ExInterlockedPushEntrySList when done. This would have abysmal
> > performance implications in a common
> > > code path, but might be acceptable for an infrequent code path,
like a
> > rare error path.
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > “Rajeev Rao” wrote in message
news:xxxxx@ntdev…
> > > >
> > > > Hi,
> > > > I need to iterate through an SLIST. There aren’t any
> > > > functions to do so. Can I access the SLIST datamembers
> > > > and move from one node to the next manually? Is this
> > > > safe?
> > > >
> > > > Rajeev
> > > >
> > > >
> > > >
________________________________________________________________________
> > > > Everything you always wanted to know about cars and bikes,now
> > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%

I’m not familiar with this particular issue, but how about having two slists
? You use one as your “front list” and the other as your “back list”. Your
items go to the front list. When you want to traverse it, repeatedly pop
from the front list and push the items to the back list. When finished, you
can pop the back list back into the front list. Or, if your items don’t
depend on sequence, use the two slists as a double buffer, and have the list
traversal be your swapbuffers.

Alberto.

-----Original Message-----
From: Gary G. Little [mailto:xxxxx@broadstor.com]
Sent: Wednesday, May 22, 2002 5:33 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

Tom,

But then are you not simply “kicking against the pricks”? or “spitting into
the wind”? The ability to traverse an SLIST does not exist in the DDK. So
either you have to invent it, or use an existing methodology that has been
blessed by MS.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Tom Stonecypher” wrote in message
news:xxxxx@ntdev…
>
> Undoubtedly a number of different solutions can be imagined if no SList is
used. I was referring to
> a method for handling the SList case, assuming it is a given that an SList
must be used. I don’t
> like the method I outlined, but it is the only answer I know to the
original question, “is there a
> safe way of traversing an SList”.
>
> regards
>
> Tom Stonecypher
> iStreamConsulting.com
>
> “Gary G. Little” wrote in message
news:xxxxx@ntdev…
> >
> > A simpler implementation would be to use a doubly linked list —
> > LIST_ENTRY.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > “Tom Stonecypher” wrote in message
> > news:xxxxx@ntdev…
> > >
> > > Hi, Rajeev,
> > >
> > > Iterating throught the SList elements is not safe. SList
manipulations
> > are performed only at the
> > > queue head, and always interlocked (an atomic update across all
> > processors). There’s no way to lock
> > > accesses on arbitrary list elements against the manipulations at the
head.
> > >
> > > The only way to safely do what you want with an SList is to pop every
> > entry using
> > > ExInterlockedPopEntrySList, save to a private list, and then push back
to
> > the list using
> > > ExInterlockedPushEntrySList when done. This would have abysmal
> > performance implications in a common
> > > code path, but might be acceptable for an infrequent code path, like a
> > rare error path.
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > “Rajeev Rao” wrote in message
news:xxxxx@ntdev…
> > > >
> > > > Hi,
> > > > I need to iterate through an SLIST. There aren’t any
> > > > functions to do so. Can I access the SLIST datamembers
> > > > and move from one node to the next manually? Is this
> > > > safe?
> > > >
> > > > Rajeev
> > > >
> > > >
> > > >
________________________________________________________________________
> > > > Everything you always wanted to know about cars and bikes,now
> > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

I don’t know how Tom’s method would not be blessed by anyone as it can’t
fail and only uses the lists access mechanisms? It is absolutely the
slowest method to handle the problem but, I believe he is correct in saying
its the only ‘safe’ way. Certainly this is true if your driver isn’t the
only entity accessing the list.

There isn’t a problem with the SList itself. There may be a problem if you
misuse it. If you have a list that you must/may access out of order, SLists
are the wrong choice. For memory lists or what have you, they are fine.
For MDL lists, just as an example, they are not.


Bill McKenzie

“Gary G. Little” wrote in message news:xxxxx@ntdevup
to > Tom,
>
> But then are you not simply “kicking against the pricks”? or “spitting
into
> the wind”? The ability to traverse an SLIST does not exist in the DDK. So
> either you have to invent it, or use an existing methodology that has been
> blessed by MS.
>
> –
> Gary G. Little
> xxxxx@broadstor.com
> xxxxx@inland.net
>
> “Tom Stonecypher” wrote in message
> news:xxxxx@ntdev…
> >
> > Undoubtedly a number of different solutions can be imagined if no SList
is
> used. I was referring to
> > a method for handling the SList case, assuming it is a given that an
SList
> must be used. I don’t
> > like the method I outlined, but it is the only answer I know to the
> original question, “is there a
> > safe way of traversing an SList”.
> >
> > regards
> >
> > Tom Stonecypher
> > iStreamConsulting.com
> >
> > “Gary G. Little” wrote in message
> news:xxxxx@ntdev…
> > >
> > > A simpler implementation would be to use a doubly linked list —
> > > LIST_ENTRY.
> > >
> > > –
> > > Gary G. Little
> > > xxxxx@broadstor.com
> > > xxxxx@inland.net
> > >
> > > “Tom Stonecypher” wrote in message
> > > news:xxxxx@ntdev…
> > > >
> > > > Hi, Rajeev,
> > > >
> > > > Iterating throught the SList elements is not safe. SList
> manipulations
> > > are performed only at the
> > > > queue head, and always interlocked (an atomic update across all
> > > processors). There’s no way to lock
> > > > accesses on arbitrary list elements against the manipulations at the
> head.
> > > >
> > > > The only way to safely do what you want with an SList is to pop
every
> > > entry using
> > > > ExInterlockedPopEntrySList, save to a private list, and then push
back
> to
> > > the list using
> > > > ExInterlockedPushEntrySList when done. This would have abysmal
> > > performance implications in a common
> > > > code path, but might be acceptable for an infrequent code path, like
a
> > > rare error path.
> > > >
> > > > Tom Stonecypher
> > > > iStreamConsulting.com
> > > >
> > > > “Rajeev Rao” wrote in message
> news:xxxxx@ntdev…
> > > > >
> > > > > Hi,
> > > > > I need to iterate through an SLIST. There aren’t any
> > > > > functions to do so. Can I access the SLIST datamembers
> > > > > and move from one node to the next manually? Is this
> > > > > safe?
> > > > >
> > > > > Rajeev
> > > > >
> > > > >
> > > > >
> ________________________________________________________________________
> > > > > Everything you always wanted to know about cars and bikes,now
> > > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>

You can also use ExInterlockedFlushSList() to grab the entire SList at
one go, which you can then traverse at your leisure. *Much* cheaper
than repeatedly calling InterlockedPopEntrySList(). If you want a FIFO
queue, just reverse the flushed list in place.

/George V. Reilly mailto:xxxxx@microsoft.com
Internet Information Server / http.sys Developer

-----Original Message-----
From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Wednesday, May 22, 2002 2:53 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

I'm not familiar with this particular issue, but how about having two
slists ? You use one as your "front list" and the other as your "back
list". Your items go to the front list. When you want to traverse it,
repeatedly pop from the front list and push the items to the back list.
When finished, you can pop the back list back into the front list. Or,
if your items don't depend on sequence, use the two slists as a double
buffer, and have the list traversal be your swapbuffers.

Alberto.

-----Original Message-----
From: Gary G. Little [mailto:xxxxx@broadstor.com]
Sent: Wednesday, May 22, 2002 5:33 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

Tom,

But then are you not simply "kicking against the pricks"? or "spitting
into the wind"? The ability to traverse an SLIST does not exist in the
DDK. So either you have to invent it, or use an existing methodology
that has been blessed by MS.

--
Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

"Tom Stonecypher" wrote in message
news:xxxxx@ntdev...
>
> Undoubtedly a number of different solutions can be imagined if no
> SList is
used. I was referring to
> a method for handling the SList case, assuming it is a given that an
> SList
must be used. I don't
> like the method I outlined, but it is the only answer I know to the
original question, "is there a
> safe way of traversing an SList".
>
> regards
>
> Tom Stonecypher
> iStreamConsulting.com
>
> "Gary G. Little" wrote in message
news:xxxxx@ntdev...
> >
> > A simpler implementation would be to use a doubly linked list ---
> > LIST_ENTRY.
> >
> > --
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > "Tom Stonecypher" wrote in message
> > news:xxxxx@ntdev...
> > >
> > > Hi, Rajeev,
> > >
> > > Iterating throught the SList elements is not safe. SList
manipulations
> > are performed only at the
> > > queue head, and always interlocked (an atomic update across all
> > processors). There's no way to lock
> > > accesses on arbitrary list elements against the manipulations at
> > > the
head.
> > >
> > > The only way to safely do what you want with an SList is to pop
> > > every
> > entry using
> > > ExInterlockedPopEntrySList, save to a private list, and then push
> > > back
to
> > the list using
> > > ExInterlockedPushEntrySList when done. This would have abysmal
> > performance implications in a common
> > > code path, but might be acceptable for an infrequent code path,
> > > like a
> > rare error path.
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > "Rajeev Rao" wrote in message
news:xxxxx@ntdev...
> > > >
> > > > Hi,
> > > > I need to iterate through an SLIST. There aren't any functions

> > > > to do so. Can I access the SLIST datamembers and move from one
> > > > node to the next manually? Is this safe?
> > > >
> > > > Rajeev
> > > >
> > > >
> > > >
________________________________________________________________________
> > > > Everything you always wanted to know about cars and bikes,now
> > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>

---
You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.

---
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%

I assume you mean that you're protecting a regular singly- or
doubly-linked list with a spinlock or an ERESOURCE. There's no point
using an SList if you guard it with an external lock.

/George V. Reilly mailto:xxxxx@microsoft.com
Internet Information Server / http.sys Developer

-----Original Message-----
From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
Sent: Wednesday, May 22, 2002 2:33 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

I guess you need to define the granularity of your lock. For example, in
some of my drivers, I have a list that keeps track of some things (i.e.
file objects, disk sectors, etc...).

I use a spinlock to protect the entire list. All list access functions
are protected. So, on a query, I first acquire the spinlock and then do
my operation and release the spinlock.

If you have a reader/writer model, you can use an ERESOURCE to protect
the list. This will allow multiple readers and a single writer; plus
ERESOURCE promotions and demotions.

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bill McKenzie
Sent: Wednesday, May 22, 2002 2:20 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

Yeah there are some lovely locations, such as
REQUEST_ALLOCATE_ADDRESS_RANGE using the incorrectly named fifo list of
MDls, which is really a lifo list
of MDLs, where you are forced to use this method. Microsoft and others
need to be VERY careful where they use SLISTS!!

--
Bill McKenzie

"Tom Stonecypher" wrote in message
news:xxxxx@ntdev...
>
> Undoubtedly a number of different solutions can be imagined if no
SList is
used. I was referring to
> a method for handling the SList case, assuming it is a given that an
SList
must be used. I don't
> like the method I outlined, but it is the only answer I know to the
original question, "is there a
> safe way of traversing an SList".
>
> regards
>
> Tom Stonecypher
> iStreamConsulting.com
>
> "Gary G. Little" wrote in message
news:xxxxx@ntdev...
> >
> > A simpler implementation would be to use a doubly linked list ---
> > LIST_ENTRY.
> >
> > --
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > "Tom Stonecypher" wrote in message
> > news:xxxxx@ntdev...
> > >
> > > Hi, Rajeev,
> > >
> > > Iterating throught the SList elements is not safe. SList
manipulations
> > are performed only at the
> > > queue head, and always interlocked (an atomic update across all
> > processors). There's no way to lock
> > > accesses on arbitrary list elements against the manipulations at
the
head.
> > >
> > > The only way to safely do what you want with an SList is to pop
every
> > entry using
> > > ExInterlockedPopEntrySList, save to a private list, and then push
back
to
> > the list using
> > > ExInterlockedPushEntrySList when done. This would have abysmal
> > performance implications in a common
> > > code path, but might be acceptable for an infrequent code path,
like a
> > rare error path.
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > "Rajeev Rao" wrote in message
news:xxxxx@ntdev...
> > > >
> > > > Hi,
> > > > I need to iterate through an SLIST. There aren't any functions

> > > > to do so. Can I access the SLIST datamembers and move from one
> > > > node to the next manually? Is this safe?
> > > >
> > > > Rajeev
> > > >
> > > >
> > > >
________________________________________________________________________
> > > > Everything you always wanted to know about cars and bikes,now
> > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>

---
You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
unsubscribe send a blank email to %%email.unsub%%

---
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%

You would still have to ExInterlockedPushEntrySList() each entry back on the
list yes? So, while it would save you some time, and that is good, it still
would not be as efficient as a doubly linked list in the same space if out
of order access were common no?


Bill McKenzie

“George Reilly” wrote in message
news:xxxxx@ntdev…

You can also use ExInterlockedFlushSList() to grab the entire SList at
one go, which you can then traverse at your leisure. Much cheaper
than repeatedly calling InterlockedPopEntrySList(). If you want a FIFO
queue, just reverse the flushed list in place.

/George V. Reilly mailto:xxxxx@microsoft.com
Internet Information Server / http.sys Developer

-----Original Message-----
From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Wednesday, May 22, 2002 2:53 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

I’m not familiar with this particular issue, but how about having two
slists ? You use one as your “front list” and the other as your “back
list”. Your items go to the front list. When you want to traverse it,
repeatedly pop from the front list and push the items to the back list.
When finished, you can pop the back list back into the front list. Or,
if your items don’t depend on sequence, use the two slists as a double
buffer, and have the list traversal be your swapbuffers.

Alberto.

-----Original Message-----
From: Gary G. Little [mailto:xxxxx@broadstor.com]
Sent: Wednesday, May 22, 2002 5:33 PM
To: NT Developers Interest List
Subject: [ntdev] Re: opaque slist?

Tom,

But then are you not simply “kicking against the pricks”? or “spitting
into the wind”? The ability to traverse an SLIST does not exist in the
DDK. So either you have to invent it, or use an existing methodology
that has been blessed by MS.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Tom Stonecypher” wrote in message
news:xxxxx@ntdev…
>
> Undoubtedly a number of different solutions can be imagined if no
> SList is
used. I was referring to
> a method for handling the SList case, assuming it is a given that an
> SList
must be used. I don’t
> like the method I outlined, but it is the only answer I know to the
original question, “is there a
> safe way of traversing an SList”.
>
> regards
>
> Tom Stonecypher
> iStreamConsulting.com
>
> “Gary G. Little” wrote in message
news:xxxxx@ntdev…
> >
> > A simpler implementation would be to use a doubly linked list —
> > LIST_ENTRY.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > “Tom Stonecypher” wrote in message
> > news:xxxxx@ntdev…
> > >
> > > Hi, Rajeev,
> > >
> > > Iterating throught the SList elements is not safe. SList
manipulations
> > are performed only at the
> > > queue head, and always interlocked (an atomic update across all
> > processors). There’s no way to lock
> > > accesses on arbitrary list elements against the manipulations at
> > > the
head.
> > >
> > > The only way to safely do what you want with an SList is to pop
> > > every
> > entry using
> > > ExInterlockedPopEntrySList, save to a private list, and then push
> > > back
to
> > the list using
> > > ExInterlockedPushEntrySList when done. This would have abysmal
> > performance implications in a common
> > > code path, but might be acceptable for an infrequent code path,
> > > like a
> > rare error path.
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > “Rajeev Rao” wrote in message
news:xxxxx@ntdev…
> > > >
> > > > Hi,
> > > > I need to iterate through an SLIST. There aren’t any functions

> > > > to do so. Can I access the SLIST datamembers and move from one
> > > > node to the next manually? Is this safe?
> > > >
> > > > Rajeev
> > > >
> > > >
> > > >
________________________________________________________________________
> > > > Everything you always wanted to know about cars and bikes,now
> > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%

Ahh, but there is the rub Bill.

Microsoft does not provide you a means of physically removing the current,
mid-list, link from a doubly-linked list. All you have is RemoveEntryList
which is nothing but a macro around a mess of FLINK=/BLINK=. If in other
parts of your code you use ExInterlockedRemoveHeadList and
ExInterlockedInsertTailList to handle normal queue processing, you do NOT
have the same degree of functionality to remove an entry from the middle of
the list. Sorry, but in the wonderful world of virtual drivers and
miniports, you do not always have the luxury of having the interrupt object
handy to call KeSynchronizeExecution, which is a royal pain in the ass to
use anyway.

I still contend the system needs ExInterlockedRemoveEntryList for orthogonal
doubly-linked list management. But, as someone said, that is my opinion, and
that plus 1.90 MIGHT buy me a cup of bad tasting coffeee at Starbucks.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Bill McKenzie” wrote in message
news:xxxxx@ntdev…
>
> You would still have to ExInterlockedPushEntrySList() each entry back on
the
> list yes? So, while it would save you some time, and that is good, it
still
> would not be as efficient as a doubly linked list in the same space if out
> of order access were common no?
>
> –
> Bill McKenzie
>
>
>
> “George Reilly” wrote in message
> news:xxxxx@ntdev…
>
> You can also use ExInterlockedFlushSList() to grab the entire SList at
> one go, which you can then traverse at your leisure. Much cheaper
> than repeatedly calling InterlockedPopEntrySList(). If you want a FIFO
> queue, just reverse the flushed list in place.
> –
> /George V. Reilly mailto:xxxxx@microsoft.com
> Internet Information Server / http.sys Developer
>
>
> -----Original Message-----
> From: Moreira, Alberto [mailto:xxxxx@compuware.com]
> Sent: Wednesday, May 22, 2002 2:53 PM
> To: NT Developers Interest List
> Subject: [ntdev] Re: opaque slist?
>
>
> I’m not familiar with this particular issue, but how about having two
> slists ? You use one as your “front list” and the other as your “back
> list”. Your items go to the front list. When you want to traverse it,
> repeatedly pop from the front list and push the items to the back list.
> When finished, you can pop the back list back into the front list. Or,
> if your items don’t depend on sequence, use the two slists as a double
> buffer, and have the list traversal be your swapbuffers.
>
> Alberto.
>
>
> -----Original Message-----
> From: Gary G. Little [mailto:xxxxx@broadstor.com]
> Sent: Wednesday, May 22, 2002 5:33 PM
> To: NT Developers Interest List
> Subject: [ntdev] Re: opaque slist?
>
>
> Tom,
>
> But then are you not simply “kicking against the pricks”? or “spitting
> into the wind”? The ability to traverse an SLIST does not exist in the
> DDK. So either you have to invent it, or use an existing methodology
> that has been blessed by MS.
>
> –
> Gary G. Little
> xxxxx@broadstor.com
> xxxxx@inland.net
>
> “Tom Stonecypher” wrote in message
> news:xxxxx@ntdev…
> >
> > Undoubtedly a number of different solutions can be imagined if no
> > SList is
> used. I was referring to
> > a method for handling the SList case, assuming it is a given that an
> > SList
> must be used. I don’t
> > like the method I outlined, but it is the only answer I know to the
> original question, “is there a
> > safe way of traversing an SList”.
> >
> > regards
> >
> > Tom Stonecypher
> > iStreamConsulting.com
> >
> > “Gary G. Little” wrote in message
> news:xxxxx@ntdev…
> > >
> > > A simpler implementation would be to use a doubly linked list —
> > > LIST_ENTRY.
> > >
> > > –
> > > Gary G. Little
> > > xxxxx@broadstor.com
> > > xxxxx@inland.net
> > >
> > > “Tom Stonecypher” wrote in message
> > > news:xxxxx@ntdev…
> > > >
> > > > Hi, Rajeev,
> > > >
> > > > Iterating throught the SList elements is not safe. SList
> manipulations
> > > are performed only at the
> > > > queue head, and always interlocked (an atomic update across all
> > > processors). There’s no way to lock
> > > > accesses on arbitrary list elements against the manipulations at
> > > > the
> head.
> > > >
> > > > The only way to safely do what you want with an SList is to pop
> > > > every
> > > entry using
> > > > ExInterlockedPopEntrySList, save to a private list, and then push
> > > > back
> to
> > > the list using
> > > > ExInterlockedPushEntrySList when done. This would have abysmal
> > > performance implications in a common
> > > > code path, but might be acceptable for an infrequent code path,
> > > > like a
> > > rare error path.
> > > >
> > > > Tom Stonecypher
> > > > iStreamConsulting.com
> > > >
> > > > “Rajeev Rao” wrote in message
> news:xxxxx@ntdev…
> > > > >
> > > > > Hi,
> > > > > I need to iterate through an SLIST. There aren’t any functions
>
> > > > > to do so. Can I access the SLIST datamembers and move from one
> > > > > node to the next manually? Is this safe?
> > > > >
> > > > > Rajeev
> > > > >
> > > > >
> > > > >
> ________________________________________________________________________
> > > > > Everything you always wanted to know about cars and bikes,now
> > > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compuware.com
> To unsubscribe send a blank email to %%email.unsub%%
>
>
>
> The contents of this e-mail are intended for the named addressee only.
> It contains information that may be confidential. Unless you are the
> named addressee or an authorized designee, you may not copy or use it,
> or disclose it to anyone else. If you received it in error please notify
> us immediately and then destroy it.
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@microsoft.com To
> unsubscribe send a blank email to %%email.unsub%%
>
>
>
>
>
>

Ah crap, good point. I didn’t even think of the doubly linked list facing
the same issues.

I have been complaining about an SList being used with the
REQUEST_ALLOCATE_ADDRESS_RANGE function, when in reality, there is nothing
they could have used here that would have been any better. So, what I
should have been complaining about is that they used one of their own
pre-cooked list structures here at all.

What a deal.


Bill McKenzie

“Gary G. Little” wrote in message
news:xxxxx@ntdev…
>
> Ahh, but there is the rub Bill.
>
> Microsoft does not provide you a means of physically removing the current,
> mid-list, link from a doubly-linked list. All you have is RemoveEntryList
> which is nothing but a macro around a mess of FLINK=/BLINK=. If in other
> parts of your code you use ExInterlockedRemoveHeadList and
> ExInterlockedInsertTailList to handle normal queue processing, you do NOT
> have the same degree of functionality to remove an entry from the middle
of
> the list. Sorry, but in the wonderful world of virtual drivers and
> miniports, you do not always have the luxury of having the interrupt
object
> handy to call KeSynchronizeExecution, which is a royal pain in the ass to
> use anyway.
>
> I still contend the system needs ExInterlockedRemoveEntryList for
orthogonal
> doubly-linked list management. But, as someone said, that is my opinion,
and
> that plus 1.90 MIGHT buy me a cup of bad tasting coffeee at Starbucks.
>
> –
> Gary G. Little
> xxxxx@broadstor.com
> xxxxx@inland.net
>
> “Bill McKenzie” wrote in message
> news:xxxxx@ntdev…
> >
> > You would still have to ExInterlockedPushEntrySList() each entry back on
> the
> > list yes? So, while it would save you some time, and that is good, it
> still
> > would not be as efficient as a doubly linked list in the same space if
out
> > of order access were common no?
> >
> > –
> > Bill McKenzie
> >
> >
> >
> > “George Reilly” wrote in message
> > news:xxxxx@ntdev…
> >
> > You can also use ExInterlockedFlushSList() to grab the entire SList at
> > one go, which you can then traverse at your leisure. Much cheaper
> > than repeatedly calling InterlockedPopEntrySList(). If you want a FIFO
> > queue, just reverse the flushed list in place.
> > –
> > /George V. Reilly mailto:xxxxx@microsoft.com
> > Internet Information Server / http.sys Developer
> >
> >
> > -----Original Message-----
> > From: Moreira, Alberto [mailto:xxxxx@compuware.com]
> > Sent: Wednesday, May 22, 2002 2:53 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: opaque slist?
> >
> >
> > I’m not familiar with this particular issue, but how about having two
> > slists ? You use one as your “front list” and the other as your “back
> > list”. Your items go to the front list. When you want to traverse it,
> > repeatedly pop from the front list and push the items to the back list.
> > When finished, you can pop the back list back into the front list. Or,
> > if your items don’t depend on sequence, use the two slists as a double
> > buffer, and have the list traversal be your swapbuffers.
> >
> > Alberto.
> >
> >
> > -----Original Message-----
> > From: Gary G. Little [mailto:xxxxx@broadstor.com]
> > Sent: Wednesday, May 22, 2002 5:33 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: opaque slist?
> >
> >
> > Tom,
> >
> > But then are you not simply “kicking against the pricks”? or “spitting
> > into the wind”? The ability to traverse an SLIST does not exist in the
> > DDK. So either you have to invent it, or use an existing methodology
> > that has been blessed by MS.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
> > “Tom Stonecypher” wrote in message
> > news:xxxxx@ntdev…
> > >
> > > Undoubtedly a number of different solutions can be imagined if no
> > > SList is
> > used. I was referring to
> > > a method for handling the SList case, assuming it is a given that an
> > > SList
> > must be used. I don’t
> > > like the method I outlined, but it is the only answer I know to the
> > original question, “is there a
> > > safe way of traversing an SList”.
> > >
> > > regards
> > >
> > > Tom Stonecypher
> > > iStreamConsulting.com
> > >
> > > “Gary G. Little” wrote in message
> > news:xxxxx@ntdev…
> > > >
> > > > A simpler implementation would be to use a doubly linked list —
> > > > LIST_ENTRY.
> > > >
> > > > –
> > > > Gary G. Little
> > > > xxxxx@broadstor.com
> > > > xxxxx@inland.net
> > > >
> > > > “Tom Stonecypher” wrote in message
> > > > news:xxxxx@ntdev…
> > > > >
> > > > > Hi, Rajeev,
> > > > >
> > > > > Iterating throught the SList elements is not safe. SList
> > manipulations
> > > > are performed only at the
> > > > > queue head, and always interlocked (an atomic update across all
> > > > processors). There’s no way to lock
> > > > > accesses on arbitrary list elements against the manipulations at
> > > > > the
> > head.
> > > > >
> > > > > The only way to safely do what you want with an SList is to pop
> > > > > every
> > > > entry using
> > > > > ExInterlockedPopEntrySList, save to a private list, and then push
> > > > > back
> > to
> > > > the list using
> > > > > ExInterlockedPushEntrySList when done. This would have abysmal
> > > > performance implications in a common
> > > > > code path, but might be acceptable for an infrequent code path,
> > > > > like a
> > > > rare error path.
> > > > >
> > > > > Tom Stonecypher
> > > > > iStreamConsulting.com
> > > > >
> > > > > “Rajeev Rao” wrote in message
> > news:xxxxx@ntdev…
> > > > > >
> > > > > > Hi,
> > > > > > I need to iterate through an SLIST. There aren’t any functions
> >
> > > > > > to do so. Can I access the SLIST datamembers and move from one
> > > > > > node to the next manually? Is this safe?
> > > > > >
> > > > > > Rajeev
> > > > > >
> > > > > >
> > > > > >
> > ________________________________________________________________________
> > > > > > Everything you always wanted to know about cars and bikes,now
> > > > > > at: http://in.autos.yahoo.com/cricket/tracker.html
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@compuware.com
> > To unsubscribe send a blank email to %%email.unsub%%
> >
> >
> >
> > The contents of this e-mail are intended for the named addressee only.
> > It contains information that may be confidential. Unless you are the
> > named addressee or an authorized designee, you may not copy or use it,
> > or disclose it to anyone else. If you received it in error please notify
> > us immediately and then destroy it.
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@microsoft.com To
> > unsubscribe send a blank email to %%email.unsub%%
> >
> >
> >
> >
> >
> >
>
>
>
>