Why do we need to diable APC's when we acquire ERESOURCE

Hi All,

Why is it a must to disable the APC’s when we acquire ERESOURCE.

In my requirement I have 2 lists where there might be many threads which use
ERESOURCE to get shared access and one thread which needs exlusive access
sometimes.
So should I disable APC’s here. If a thread is suspended while it holds a
shared permission there should not be a any problem for theread requesting
exclusive access. But I disable APC’s for the thread that needs exclusive
access, am I correct?

Any information is helpful.

Thanks,
Kedar.

We disable APCs to ensure we can build deadlock-free systems that use
ERESOURCES.

Suppose you have two paths in your driver:

Path # 1: Acquire ERESOURCE ‘X’, perform work, release ERESOURCE ‘X’
Path # 2: Acquire ERESOURCE ‘Y’, perform work, release ERESOURCE ‘Y’

Now suppose you allow APC’s in the “perform work” phase above: how do
you ensure that you have a deadlock-free system? Generally, we build
deadlock free systems by using lock hierarchies. The point is that if
we allow Thread ‘A’ to start running Path # 1 and then take an APC to
run Path # 2, and Thread ‘B’ is running Path # 2 and takes an APC that
tries to run Path # 1, we’ve introduced a lock inversion and eventually
we’ll get a deadlock here.

By blocking APCs in between resource acquisition, we control the ability
of the system to grab arbitrary locks in arbitrary order.

Oh - I hope that people have picked up on the new APC control mechanism
in Windows Server 2003 (one dev described it to us as “IRQL 1.5” -
somewhere between PASSIVE_LEVEL and APC_LEVEL.)

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kedar
Sent: Friday, May 07, 2004 3:29 AM
To: ntfsd redirect
Subject: [ntfsd] Why do we need to diable APC’s when we acquire
ERESOURCE

Hi All,

Why is it a must to disable the APC’s when we acquire ERESOURCE.

In my requirement I have 2 lists where there might be many threads which
use ERESOURCE to get shared access and one thread which needs exlusive
access sometimes.
So should I disable APC’s here. If a thread is suspended while it holds
a shared permission there should not be a any problem for theread
requesting exclusive access. But I disable APC’s for the thread that
needs exclusive access, am I correct?

Any information is helpful.

Thanks,
Kedar.


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com

All this stuff with disabling APC’s is rather complicated. At least for me.
I despaired to understand it in all details. I’m just taking this as a rule.
And everything’s working : )

–htfv

“Kedar” wrote in message news:xxxxx@ntfsd…
> Hi All,
>
> Why is it a must to disable the APC’s when we acquire ERESOURCE.
>
> In my requirement I have 2 lists where there might be many threads which
> use
> ERESOURCE to get shared access and one thread which needs exlusive access
> sometimes.
> So should I disable APC’s here. If a thread is suspended while it holds a
> shared permission there should not be a any problem for theread requesting
> exclusive access. But I disable APC’s for the thread that needs exclusive
> access, am I correct?
>
> Any information is helpful.
>
> Thanks,
> Kedar.
>
>
>

> All this stuff with disabling APC’s is rather complicated. At least for
me.

I despaired to understand it in all details. I’m just taking this as a
rule.

So do I. At least Driver Verifier will not bugcheck
if I acquire a resource :-))

L.