System DPC and Custom DPC

Hello,

I am developing a WDM driver on x86 for a streaming PCI device. In ISR, if
I call IoRequestDpc() followed by KeInsertQueueDpc() (for some custom DPC
object) which Dpc will be called first by the system?

Is there any performance benefit available by using system DPC over custom
DPC?

Regards,
Girish

If you are queueing the dpcs to the same processor at the same dpc
priority then they will be called in fifo order.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Girish
Gurunathan
Sent: Monday, May 20, 2002 6:24 AM
To: NT Developers Interest List
Subject: [ntdev] System DPC and Custom DPC

Hello,

I am developing a WDM driver on x86 for a streaming PCI
device. In ISR, if I call IoRequestDpc() followed by
KeInsertQueueDpc() (for some custom DPC
object) which Dpc will be called first by the system?

Is there any performance benefit available by using system
DPC over custom DPC?

Regards,
Girish


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

> I call IoRequestDpc() followed by KeInsertQueueDpc() (for some custom DPC

object) which Dpc will be called first by the system?

Is there any performance benefit available by using system DPC over custom
DPC?

They are the same, since IoRequestDpc is a macro around KeInsertQueueDpc.
DPC order is undefined on SMP machine, so, do not rely on it, do all job sequentially from the first DPC.

Max

There’s no guarantee on the order in which the DPCs will be called.

-p

-----Original Message-----
From: Girish Gurunathan [mailto:xxxxx@wipro.com]
Sent: Monday, May 20, 2002 3:24 AM
To: NT Developers Interest List
Subject: [ntdev] System DPC and Custom DPC

Hello,

I am developing a WDM driver on x86 for a streaming PCI device. In ISR,
if I call IoRequestDpc() followed by KeInsertQueueDpc() (for some custom
DPC
object) which Dpc will be called first by the system?

Is there any performance benefit available by using system DPC over
custom DPC?

Regards,
Girish


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

Hmmm… I think I have to disagree with both you amd max. As I said, if the
dpc’s are queued to the same processor at the same priority, the order in
which they are queued is the order in which they are executed. Within a
single thread of execution ‘the order in which they are queued’ is not
ambiguous. Across multiple threads there may be no way to determine what
that order is. I suppose some future version of NT *could* decide to dequeue
in lifo or some other order, so in that sense there is no guarantee.

-----Original Message-----
From: Peter Wieland [mailto:xxxxx@windows.microsoft.com]
Sent: Monday, May 20, 2002 1:26 PM
To: NT Developers Interest List
Subject: [ntdev] RE: System DPC and Custom DPC

There’s no guarantee on the order in which the DPCs will be called.

-p

-----Original Message-----
From: Girish Gurunathan [mailto:xxxxx@wipro.com]
Sent: Monday, May 20, 2002 3:24 AM
To: NT Developers Interest List
Subject: [ntdev] System DPC and Custom DPC

Hello,

I am developing a WDM driver on x86 for a streaming PCI
device. In ISR, if I call IoRequestDpc() followed by
KeInsertQueueDpc() (for some custom DPC
object) which Dpc will be called first by the system?

Is there any performance benefit available by using system
DPC over custom DPC?

Regards,
Girish


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


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

your last sentence is the most important point. Since there is nothing
which specifies that DPCs will be run in the order they were queued then
there’s no guarantee that future system changes won’t break drivers
which are dependant on such an undocumented detail of the current
implementation.

if you really need to run two things back-to-back at DPC level you
should queue one DPC and have it do both of them. Or have the first DPC
queue the second when it’s safe for the second to run.

-p

-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Monday, May 20, 2002 10:38 AM
To: NT Developers Interest List
Subject: [ntdev] RE: System DPC and Custom DPC

Hmmm… I think I have to disagree with both you amd max. As I said, if
the dpc’s are queued to the same processor at the same priority, the
order in which they are queued is the order in which they are executed.
Within a single thread of execution ‘the order in which they are queued’
is not ambiguous. Across multiple threads there may be no way to
determine what that order is. I suppose some future version of NT
*could* decide to dequeue in lifo or some other order, so in that sense
there is no guarantee.

-----Original Message-----
From: Peter Wieland [mailto:xxxxx@windows.microsoft.com]
Sent: Monday, May 20, 2002 1:26 PM
To: NT Developers Interest List
Subject: [ntdev] RE: System DPC and Custom DPC

There’s no guarantee on the order in which the DPCs will be called.

-p

-----Original Message-----
From: Girish Gurunathan [mailto:xxxxx@wipro.com]
Sent: Monday, May 20, 2002 3:24 AM
To: NT Developers Interest List
Subject: [ntdev] System DPC and Custom DPC

Hello,

I am developing a WDM driver on x86 for a streaming PCI
device. In ISR, if I call IoRequestDpc() followed by
KeInsertQueueDpc() (for some custom DPC
object) which Dpc will be called first by the system?

Is there any performance benefit available by using system
DPC over custom DPC?

Regards,
Girish


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


You are currently subscribed to ntdev as:
xxxxx@stratus.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%%

Even better, MUCH better in fact would be if they could document either that
you cannot depend on the order or that you can and how.


Bill McKenzie

“Peter Wieland” wrote in message
news:xxxxx@ntdev…

your last sentence is the most important point. Since there is nothing
which specifies that DPCs will be run in the order they were queued then
there’s no guarantee that future system changes won’t break drivers
which are dependant on such an undocumented detail of the current
implementation.

if you really need to run two things back-to-back at DPC level you
should queue one DPC and have it do both of them. Or have the first DPC
queue the second when it’s safe for the second to run.

-p

-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Monday, May 20, 2002 10:38 AM
To: NT Developers Interest List
Subject: [ntdev] RE: System DPC and Custom DPC

Hmmm… I think I have to disagree with both you amd max. As I said, if
the dpc’s are queued to the same processor at the same priority, the
order in which they are queued is the order in which they are executed.
Within a single thread of execution ‘the order in which they are queued’
is not ambiguous. Across multiple threads there may be no way to
determine what that order is. I suppose some future version of NT
could decide to dequeue in lifo or some other order, so in that sense
there is no guarantee.

> -----Original Message-----
> From: Peter Wieland [mailto:xxxxx@windows.microsoft.com]
> Sent: Monday, May 20, 2002 1:26 PM
> To: NT Developers Interest List
> Subject: [ntdev] RE: System DPC and Custom DPC
>
>
> There’s no guarantee on the order in which the DPCs will be called.
>
> -p
>
> -----Original Message-----
> From: Girish Gurunathan [mailto:xxxxx@wipro.com]
> Sent: Monday, May 20, 2002 3:24 AM
> To: NT Developers Interest List
> Subject: [ntdev] System DPC and Custom DPC
>
>
> Hello,
>
> I am developing a WDM driver on x86 for a streaming PCI
> device. In ISR, if I call IoRequestDpc() followed by
> KeInsertQueueDpc() (for some custom DPC
> object) which Dpc will be called first by the system?
>
> Is there any performance benefit available by using system
> DPC over custom DPC?
>
> Regards,
> Girish
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@microsoft.com To unsubscribe send a blank email to
> %%email.unsub%%
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@stratus.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%%

> > I call IoRequestDpc() followed by KeInsertQueueDpc() (for

some custom DPC
> object) which Dpc will be called first by the system?
>
> Is there any performance benefit available by using system
DPC over custom
> DPC?

IoRequestDPC is nothing but …

#define IoRequestDpc( DeviceObject, Irp, Context ) ( \
http: KeInsertQueueDpc(
&(DeviceObject)->Dpc, (Irp), (Context) ) )

if you call KeInsertQueueDpc through the IoRequestDpc macro then the DPC
object’s SystemArgument1 is set to IRP and SystemArgument2 is set to the
Context. However , the DPC Object’s Priority is set to Medium by default in
KeInsertQueueDpc. So no help in performance with the use of either.

You may however think of changing this priority to High by calling the
undocumented KeSetImportanceDpc. In that case there would be less latency
between your ISR and DPC as compared to the ISR and DPC created through the
normal IoRequestDpc() call sequence…

BTW are u the same Girish of Wipro Pune whom I knew … I wanted to meet
you when I left Wipro … I had done some more intersting work on QOS of
Network processors and wanted to send them to u …

>
> They are the same, since IoRequestDpc is a macro around
> KeInsertQueueDpc.
> DPC order is undefined on SMP machine, so, do not rely on it,
> do all job sequentially from the first DPC.
>
> Max
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@quark.co.in
> To unsubscribe send a blank email to %%email.unsub%%
></http:>

> that order is. I suppose some future version of NT *could* decide to dequeue

in lifo or some other order, so in that sense there is no guarantee.

Consider DPCs as interrupts. You see - relying on IRQs to arrive in some order is a bad idea :slight_smile:

Max