Deffered Procedure Call WindowsNT

Hi all

Since newbie in Driver Development,I want to know at an instant how many
Deffered Procedure Calls(DPC) execute on Single Processor Windows NT system
?
and when does it execute , when IRQL drops from HIGH_LEVEL to DISPATCH_LEVEL
or it raised from LOW_LEVEL to DISPATCH_LEVEL or only DISPATCH_LEVEL is
required no matter it comes down from above or raised from LOW_LEVEL ?

Thanks in advance.
Deepak


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

>Since newbie in Driver Development,I want to know at an instant how many

Deffered Procedure Calls(DPC) execute on Single Processor Windows NT system

One, they execute serially and one DPC can’t preempt another DPC. The order
they execute in can be fiddled some by a parameter when the DPC is queued.

and when does it execute , when IRQL drops from HIGH_LEVEL to DISPATCH_LEVEL
or it raised from LOW_LEVEL to DISPATCH_LEVEL or only DISPATCH_LEVEL is
required no matter it comes down from above or raised from LOW_LEVEL ?

If there are DPC’s to execute, they will essentially interrupt any code at
lower than DISPATCH_LEVEL. So if your already executing at say
PASSIVE_LEVEL, there must not be any DPC’s queued. If your running at
PASSIVE_LEVEL, and you raise the IRQL to DISPATCH_LEVEL with an kernel API
call, and something you do queues a DPC, it will run when you try to lower
your IRQL back to PASSIVE_LEVEL…

I tend to think of DPC’s executing when the processor drops back to
DISPATCH_LEVEL (or lower) from any higher level, basically like an
interrupt at lower priority than any hardware interrupt. I’m not sure if
there is other OS code that runs at DISPATCH_LEVEL that will execute before
or between things in the DPC queue (like scheduling?).

A DPC you just queued from an ISR also may not immediately run after your
return from the ISR, as other DPC’s may be in the queue ahead of it, or you
may have interrupted a DPC to run the ISR.

DPC’s are termed interruptible, but not preemptable, which means if a DPC
starts running, no other code at DISPATCH_LEVEL will preempt the execution,
although code at higher levels might interrupt it to run. DPC’s can also
never block, as an attempt to switch thread context violates the definition
of not preemptable. DPC’s also execute in an arbitrary thread/process
context, so the user mode part of the address space (generally < 2 GB) has
some arbitrary memory mapping.

Perhaps some of the kernel trainers here have good words for newbie driver
writes.

  • Jan

You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Since newbie in Driver Development,I want to know at an instant how many

Deffered Procedure Calls(DPC) execute on Single Processor Windows NT
system
?
and when does it execute , when IRQL drops from HIGH_LEVEL to
DISPATCH_LEVEL
or it raised from LOW_LEVEL to DISPATCH_LEVEL or only DISPATCH_LEVEL is
required no matter it comes down from above or raised from LOW_LEVEL ?

Only 1 DPC can run a time on given CPU. The CPU will not start the next DPC
till the current DPC will be executed till the end.

DPCs are executed by KiRetireDpcList function which runs any time just
before somebody wants to lower the IRQL from DISPATCH_LEVEL to <
DISPATCH_LEVEL.

KeReleaseSpinLock and the ISR epilog are 2 examples.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> although code at higher levels might interrupt it to run. DPC’s can also

never block, as an attempt to switch thread context violates the
definition
of not preemptable.

Yes. Also a DPC cannot touch anything pageable since the page fault handler
blocks.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Just for clarification, I thought that only one DPC would run on a machine
at any time regardless of how many CPU’s it has (at least in Win2K). If
that is not the case, I need to rethink the synchronization in one of my
projects.

Marc Reinig
System Solutions

-----Original Message-----

Since newbie in Driver Development,I want to know at an instant how many
Deffered Procedure Calls(DPC) execute on Single Processor Windows NT
system
?
and when does it execute , when IRQL drops from HIGH_LEVEL to
DISPATCH_LEVEL
or it raised from LOW_LEVEL to DISPATCH_LEVEL or only DISPATCH_LEVEL is
required no matter it comes down from above or raised from LOW_LEVEL ?

Only 1 DPC can run a time on given CPU. The CPU will not start the next DPC
till the current DPC will be executed till the end.

DPCs are executed by KiRetireDpcList function which runs any time just
before somebody wants to lower the IRQL from DISPATCH_LEVEL to <
DISPATCH_LEVEL.

KeReleaseSpinLock and the ISR epilog are 2 examples.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Not so. One DPC per CPU.
Use spinlocks to synchronize them.

Max

----- Original Message -----
From: “Marc Reinig”
To: “NT Developers Interest List”
Sent: Sunday, September 23, 2001 9:55 PM
Subject: [ntdev] Re: Deffered Procedure Call WindowsNT

> Just for clarification, I thought that only one DPC would run on a
machine
> at any time regardless of how many CPU’s it has (at least in Win2K). If
> that is not the case, I need to rethink the synchronization in one of my
> projects.
>
> Marc Reinig
> System Solutions
>
>
> -----Original Message-----
> > Since newbie in Driver Development,I want to know at an instant how many
> > Deffered Procedure Calls(DPC) execute on Single Processor Windows NT
> system
> > ?
> > and when does it execute , when IRQL drops from HIGH_LEVEL to
> DISPATCH_LEVEL
> > or it raised from LOW_LEVEL to DISPATCH_LEVEL or only DISPATCH_LEVEL
is
> > required no matter it comes down from above or raised from LOW_LEVEL ?
>
> Only 1 DPC can run a time on given CPU. The CPU will not start the next
DPC
> till the current DPC will be executed till the end.
>
> DPCs are executed by KiRetireDpcList function which runs any time just
> before somebody wants to lower the IRQL from DISPATCH_LEVEL to <
> DISPATCH_LEVEL.
>
> KeReleaseSpinLock and the ISR epilog are 2 examples.
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Rethink it … it is quite possible for as many DPC’s to be running as you
have processors.

Gary

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 10:55 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deffered Procedure Call WindowsNT

Just for clarification, I thought that only one DPC would run on a machine
at any time regardless of how many CPU’s it has (at least in Win2K). If
that is not the case, I need to rethink the synchronization in one of my
projects.

Marc Reinig
System Solutions

-----Original Message-----

Since newbie in Driver Development,I want to know at an instant how many
Deffered Procedure Calls(DPC) execute on Single Processor Windows NT
system
?
and when does it execute , when IRQL drops from HIGH_LEVEL to
DISPATCH_LEVEL
or it raised from LOW_LEVEL to DISPATCH_LEVEL or only DISPATCH_LEVEL is
required no matter it comes down from above or raised from LOW_LEVEL ?

Only 1 DPC can run a time on given CPU. The CPU will not start the next DPC
till the current DPC will be executed till the end.

DPCs are executed by KiRetireDpcList function which runs any time just
before somebody wants to lower the IRQL from DISPATCH_LEVEL to <
DISPATCH_LEVEL.

KeReleaseSpinLock and the ISR epilog are 2 examples.


You are currently subscribed to ntdev as: xxxxx@inland.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Also, as soon as a particular DPC starts on one CPU its possible to queue the same DPC on another CPU.

Therefore the same DPC function can be running for the same DPC object on two CPUs at once.

There are some simple strategies with interlocked instructions to ensure that only one DPC runs at a time.
Alternately, spinlocks can be used to synchronize when this occurs.

-DH

----- Original Message -----
From: “Gary G. Little”
To: “NT Developers Interest List”
Sent: Sunday, September 23, 2001 9:13 PM
Subject: [ntdev] Re: Deffered Procedure Call WindowsNT

> Rethink it … it is quite possible for as many DPC’s to be running as you
> have processors.
>
> Gary
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Marc Reinig
> Sent: Sunday, September 23, 2001 10:55 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: Deffered Procedure Call WindowsNT
>
> Just for clarification, I thought that only one DPC would run on a machine
> at any time regardless of how many CPU’s it has (at least in Win2K). If
> that is not the case, I need to rethink the synchronization in one of my
> projects.
>
> Marc Reinig
> System Solutions
>
>
> -----Original Message-----
> > Since newbie in Driver Development,I want to know at an instant how many
> > Deffered Procedure Calls(DPC) execute on Single Processor Windows NT
> system
> > ?
> > and when does it execute , when IRQL drops from HIGH_LEVEL to
> DISPATCH_LEVEL
> > or it raised from LOW_LEVEL to DISPATCH_LEVEL or only DISPATCH_LEVEL is
> > required no matter it comes down from above or raised from LOW_LEVEL ?
>
> Only 1 DPC can run a time on given CPU. The CPU will not start the next DPC
> till the current DPC will be executed till the end.
>
> DPCs are executed by KiRetireDpcList function which runs any time just
> before somebody wants to lower the IRQL from DISPATCH_LEVEL to <
> DISPATCH_LEVEL.
>
> KeReleaseSpinLock and the ISR epilog are 2 examples.
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@inland.net
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@syssoftsol.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com