WDFCOLLECTION and getting items

I noticed that there is a WdfCollectionGetFirstItem and a
WdfCollectionGetLastItem, but there is no WdfCollectoinGetNextItem.

Why is that? Having a GetNextItem would simplify iterating throiugh
items in a collection (may even be faster than going by index?)

I propose this for a new method:

WDFOBJECT WdfCollectionGetNextItem(WDFCOLLECTION Collection, WDFOBJECT
Item);

where Item is retrieved by a previous call (e.g. from
WdfCollectionGetFirstItem)

If Item is NULL it could retrieve the first item.

I’m assuming that the collections are built around the linked list API.
If that assumption is wrong, then I’d like to know what the underlaying
implementation is. I may just want to drop back to regular old linked
lists.

Beverly

WDFCOLLECTIONs are linked list, but a WDFOBJECT does not have storage in it for a node entry, so there is no way from WDFOBJECT->location in the list. This is why WdfCollecitonAddItem can fail as wel.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Saturday, August 05, 2006 9:46 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WDFCOLLECTION and getting items

I noticed that there is a WdfCollectionGetFirstItem and a WdfCollectionGetLastItem, but there is no WdfCollectoinGetNextItem.
?
Why is that? Having a GetNextItem would simplify iterating throiugh items in a collection (may even be faster than going by index?)
?
I propose this for a new method:
?
WDFOBJECT WdfCollectionGetNextItem(WDFCOLLECTION Collection, WDFOBJECT Item);
?
where Item is retrieved by a previous call (e.g.? from?WdfCollectionGetFirstItem)
?
If Item is NULL it could retrieve the first item.
?
I’m assuming that the collections are built around the linked list API. If that assumption is wrong, then I’d like to know what the underlaying implementation is. I may just want to drop back to regular old linked lists.
?
Beverly


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Can that be changed?

That implementation makes collections really poor performers for anything other than operating on the first or last item.

It looks like I definitely want to abandon the use of collections in favor of linked lists if I want any kind of performance in iteration.

Beverly

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Saturday, August 05, 2006 2:46 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] WDFCOLLECTION and getting items

WDFCOLLECTIONs are linked list, but a WDFOBJECT does not have storage in it for a node entry, so there is no way from WDFOBJECT->location in the list. This is why WdfCollecitonAddItem can fail as wel.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Saturday, August 05, 2006 9:46 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WDFCOLLECTION and getting items

I noticed that there is a WdfCollectionGetFirstItem and a WdfCollectionGetLastItem, but there is no WdfCollectoinGetNextItem.
?
Why is that? Having a GetNextItem would simplify iterating throiugh items in a collection (may even be faster than going by index?)
?
I propose this for a new method:
?
WDFOBJECT WdfCollectionGetNextItem(WDFCOLLECTION Collection, WDFOBJECT Item);
?
where Item is retrieved by a previous call (e.g.? from?WdfCollectionGetFirstItem)
?
If Item is NULL it could retrieve the first item.
?
I’m assuming that the collections are built around the linked list API. If that assumption is wrong, then I’d like to know what the underlaying implementation is. I may just want to drop back to regular old linked lists.
?
Beverly


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

There are 2 issues here:

  1. it would grow every single KMDF object, but very few objects are put in collections, so increased memory usage is not beneficial compared to its use

  2. an object can be in more then one collection at a time. embedding a node entry would only work for the first collection it is added to. This would make the collection and the object quite a bit more complicated.

A good old fashioned LIST_ENTRY head and a LIST_ENTRY in an object context work very well. We are working on a better containter story for future versions of KMDF, but WDFCOLLECTION was meant for a very simple list replacement and not much more.

Another note, you must synchronize access to the WDFCOLLECTION. While the collection itself maintains a consistent state w/ its own internal lock, the state can change from thread to thread unless you synchronize your own access to it.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Saturday, August 05, 2006 12:18 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] WDFCOLLECTION and getting items

Can that be changed?

That implementation makes collections really poor performers for anything other than operating on the first or last item.

It looks like I definitely want to abandon the use of collections in favor of linked lists if I want any kind of performance in iteration.

Beverly

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Saturday, August 05, 2006 2:46 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] WDFCOLLECTION and getting items

WDFCOLLECTIONs are linked list, but a WDFOBJECT does not have storage in it for a node entry, so there is no way from WDFOBJECT->location in the list. This is why WdfCollecitonAddItem can fail as wel.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Saturday, August 05, 2006 9:46 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WDFCOLLECTION and getting items

I noticed that there is a WdfCollectionGetFirstItem and a WdfCollectionGetLastItem, but there is no WdfCollectoinGetNextItem.
?
Why is that? Having a GetNextItem would simplify iterating throiugh items in a collection (may even be faster than going by index?)
?
I propose this for a new method:
?
WDFOBJECT WdfCollectionGetNextItem(WDFCOLLECTION Collection, WDFOBJECT Item);
?
where Item is retrieved by a previous call (e.g.? from?WdfCollectionGetFirstItem)
?
If Item is NULL it could retrieve the first item.
?
I’m assuming that the collections are built around the linked list API. If that assumption is wrong, then I’d like to know what the underlaying implementation is. I may just want to drop back to regular old linked lists.
?
Beverly


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I have been protecting the collection accesses with locks, so no problem there. But it looks like I’ll need to use linked lists instead of the collections for performance.

Thanks for the info.

Beverly

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Saturday, August 05, 2006 3:47 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] WDFCOLLECTION and getting items

There are 2 issues here:

  1. it would grow every single KMDF object, but very few objects are put in collections, so increased memory usage is not beneficial compared to its use

  2. an object can be in more then one collection at a time. embedding a node entry would only work for the first collection it is added to. This would make the collection and the object quite a bit more complicated.

A good old fashioned LIST_ENTRY head and a LIST_ENTRY in an object context work very well. We are working on a better containter story for future versions of KMDF, but WDFCOLLECTION was meant for a very simple list replacement and not much more.

Another note, you must synchronize access to the WDFCOLLECTION. While the collection itself maintains a consistent state w/ its own internal lock, the state can change from thread to thread unless you synchronize your own access to it.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Saturday, August 05, 2006 12:18 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] WDFCOLLECTION and getting items

Can that be changed?

That implementation makes collections really poor performers for anything other than operating on the first or last item.

It looks like I definitely want to abandon the use of collections in favor of linked lists if I want any kind of performance in iteration.

Beverly

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Saturday, August 05, 2006 2:46 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] WDFCOLLECTION and getting items

WDFCOLLECTIONs are linked list, but a WDFOBJECT does not have storage in it for a node entry, so there is no way from WDFOBJECT->location in the list. This is why WdfCollecitonAddItem can fail as wel.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Saturday, August 05, 2006 9:46 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WDFCOLLECTION and getting items

I noticed that there is a WdfCollectionGetFirstItem and a WdfCollectionGetLastItem, but there is no WdfCollectoinGetNextItem.
?
Why is that? Having a GetNextItem would simplify iterating throiugh items in a collection (may even be faster than going by index?)
?
I propose this for a new method:
?
WDFOBJECT WdfCollectionGetNextItem(WDFCOLLECTION Collection, WDFOBJECT Item);
?
where Item is retrieved by a previous call (e.g.? from?WdfCollectionGetFirstItem)
?
If Item is NULL it could retrieve the first item.
?
I’m assuming that the collections are built around the linked list API. If that assumption is wrong, then I’d like to know what the underlaying implementation is. I may just want to drop back to regular old linked lists.
?
Beverly


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer