Michael,
Wouldn’t it just be easier to reference count your structure so that
you can track down your problem?
–Mark Cariddi
OSR, Open Systems Resources, Inc.
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Zhu
Sent: Thursday, November 19, 2009 10:48 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Question about ExDeleteResourceLite()
Is there any specific reason why I couldn’t rely on them? Maybe because
of the following description in WDK?
"
ExGetExclusiveWaiterCount can be called to get an estimate of how many
other threads might be waiting to modify the data protected by a
particular resource variable. The caller cannot assume that the returned
value remains constant for any particular interval.
"
On Thu, Nov 19, 2009 at 10:25 AM, Tracy Camp wrote:
You have a design issue in that your design has to know when it is safe
to delete a resource. It is never reasonable or safe to do what you
propose. It may be reasonable and safe to ASSERT these things to verify
your design, but not to rely upon them as your design.
t.
On Thu, 19 Nov 2009, Michael Zhu wrote:
Thanks for the response. I totally understand and agree what you
said. And I
know there is a design issue in my code. And I am working on
that to improve
the design.
But is it reasonable or safe to check the
NumberOfSharedWaiters/NumberOfExclusiveWaiters before I delete
the resource?
In other words how I can detect if a resource has been in use
before I
delete it? And if Resource->NumberOfExclusiveWaiters > 0 or
Resource->NumberOfSharedWaiters > 0, then I can be sure that the
resource is
in use?
Thanks.
On Wed, Nov 18, 2009 at 5:06 PM, Skywing
wrote:
This is a general design issue and is not specific to eresource
objects.
You must design your program so that you only delete an object
when you’ve
ensured there are no users (and can never be more).
While there are general design patterns for this you need to
look at your
program and decide what’s best (e.g. maybe you remove something
from a list
that’s used to acquire new references to an object, then delete
the object
when the refcount goes to zero).
In general it is not safe to delete something out from under
someone who is
using it – the same goes for plain memory allocations or any
other source
of resources.
- S
------------------------------
From: Michael Zhu
Sent: Wednesday, November 18, 2009 12:41
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Question about ExDeleteResourceLite()
That is what I am trying to solve. I have a system crash when
one of my
driver’s threads tried to call ExReleaseResourceForThreadLite()
for a
ERESOURCE which has already been deleted and freed. That is why
I asked if I
need to check there is any shared or exclusive waiter for the
ERESOURCE
before I can safely delete and free it.
On Wed, Nov 18, 2009 at 3:14 PM, Skywing
wrote:
In general, should you find yourself trying to write these sort
of
constructs, that’s typically a sign that you’ve got an object
lifecycle
management issue.
What happens if someone tries to re-acquire the lock while
you’re deleting
it, for instance?
It’s really only safe to deallocate (any) data structure when
you know
that there are no more users of it and that there will never be
any future
users of it (or attempted future users) under any circumstances.
- S
------------------------------
From: Michael Zhu
Sent: Wednesday, November 18, 2009 11:57
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Question about ExDeleteResourceLite()
I have a question about ExDeleteResourceLite(). Is it safe to
call this
routine when Resource->NumberOfExclusiveWaiters > 0 or
Resource->NumberOfSharedWaiters > 0? Do I need to do the
following?
do {
if((Resource->NumberOfSharedWaiters == 0) &&
(Resource->NumberOfExclusiveWaiters == 0)) {
ExDeleteResourceLite(Resource)
break;
}
} while(1)
Thanks.
— NTFSD is sponsored by OSR For our schedule of debugging and
file
system seminars (including our new fs mini-filter seminar)
visit:
http://www.osr.com/seminars To unsubscribe, visit the List
Server section
of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
NTFSD is sponsored by OSR
For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
— NTFSD is sponsored by OSR For our schedule of debugging and
file system
seminars (including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars To unsubscribe, visit the List
Server section
of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
NTFSD is sponsored by OSR
For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
NTFSD is sponsored by OSR
For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
NTFSD is sponsored by OSR
For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
— NTFSD is sponsored by OSR For our schedule of debugging and file
system seminars (including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars To unsubscribe, visit the List Server
section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer