I just got back from being gone for a week. The order of cleanup on contexts on one object is not currently defined, I am going to talk with the team to see if we want to commit to documenting the ordering of the context cleanup calls or not....and yes, you are right, the source would tell you what happens, but you would get the same data empirically. The source would not tell you if this is an explicit contract or not anyways, it just makes function calls through function pointers ;).
Where the default context (where default is the context specified in the WDF_OBJECT_ATTRIBUTES during the Create call or the context specified for requests or file objects during device init) is also not documented (but empirically you can see that it is always the first one), I will see if we want to commit to ordering here as well.
And to be clear about ordering overall between different objects (vs your question of different contexts on the same object), the only guarantee is that all child objects of a parent object will be cleaned up before the parent object's cleanup callback is called, there is intentionally no ordering guarantee between siblings who share the same parent.
Thx
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Philip D. Barila
Sent: Monday, September 17, 2007 9:14 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] KMDF object context cleanup order
I know replying to your own post isn't the best form, but I still need an
answer, and only Microsoft can provide one that represents the intended
contract, since the documentation is silent on this, and relying on observed
behavior may not be consistent with what was intended.
This is exactly the kind of situation that Ray Trent's well-reasoned reply
to Bill McKenzie addresses. If I had the source, I could ascertain whether
there is a reasonable expectation of deterministic behavior, or if there is
a potential for random behavior here. Whether I have the source or not, I
can determine what behavior I see empirically.
The important point here is this: Neither conclusion may represent the
contract designer's intent, and relying on it will either result in a broken
driver if MSFT changes the behavior to match the intended contract, or it
will result in MSFT being locked into the current behavior, due to drivers
relying on it.
So could someone from MSFT please state the intent of the contract here?
Is there intended to be an explicit order of cleanup for multiple WDFOBJECT
contexts? FIFO? LIFO? Random? How do default contexts fit into that
order? Last? First? Also random?
Phil
Philip D. Barila
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
"Philip D. Barila" wrote in message
news:xxxxx@ntdev...
>I have a KMDF driver (actually, a bunch of them that share a common wrapper
>around stuff like ExAllocatePoolWithTag() and WdfYyyZzz() calls) that
>configures a default context for the WDFDEVICE and stores some stuff in
>that. Turns out that I need to store a small subset of that information in
>a context attached to a WDFDRIVER, and I don't really want to attach the
>entire device context, just that small part. Since the code that uses this
>particular bit of information could just as easily use the same context
>definition for any WDFOBJECT, I had the bright idea that I could use
>WdfObjectAllocateContext() to allocate that separate context blob, and
>everyone is happy. Except, I can't cleanup the small context I've
>allocated until I've cleaned up the default context first.
>
> Are there any guarantees on the order of context cleanup callbacks for a
> single object? Or do you only get one context cleanup for a WDFOBJECT,
> which would allow me to cleanup both contexts in the order I choose? What
> happens if I pass one EvtCleanupCallback in the WDF_OBJECT_ATTRIBUTES I
> use to setup the default context, and a different one in the attributes I
> pass to WdfObjectAllocateContext()?
---
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
OSR Seminars – OSR
To unsubscribe, visit the List Server section of OSR Online at ListServer/Forum