Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 11: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


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

I got this from Baker/Lozano, “The Windows 2000 Device Driver Book”. Under
Behavior of DPC’s, in chapter 3 they say: “The DPC architecture prevents any
two DPCs from executing simultaneously, even on a multiprocessor machine.
Thus resources shared by different DPC routines do not need to worry about
synchronization.”

Haven’t reviewed the errata, can’t get to their site. However, on checking
Oney, Viscarola and Mason, and Decker and Newcomer, they all state the
opposite. So, in go the spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 11: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


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

The fact that Baker still has this wrong, in the second edition of his book,
is appalling. From the quote, it is not even clear that the authors
understand what a DPC is, much less what its concurrency might be. Perhaps
there is some other explanation of this quote that makes sense?

-----Original Message-----
From: Marc Reinig [mailto:xxxxx@pacbell.net]
Sent: Monday, September 24, 2001 12:31 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I got this from Baker/Lozano, “The Windows 2000 Device Driver Book”. Under
Behavior of DPC’s, in chapter 3 they say: “The DPC architecture prevents any
two DPCs from executing simultaneously, even on a multiprocessor machine.
Thus resources shared by different DPC routines do not need to worry about
synchronization.”

Haven’t reviewed the errata, can’t get to their site. However, on checking
Oney, Viscarola and Mason, and Decker and Newcomer, they all state the
opposite. So, in go the spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 11: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


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


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

Yeah … and Little says the opposite of Baker/Lozano, as well. And that
comes from three years of getting screwed by multiple CPUs running the same
DPC, multiple times.

:slight_smile:

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Marc Reinig [mailto:xxxxx@pacbell.net]
Sent: Monday, September 24, 2001 9:31 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I got this from Baker/Lozano, “The Windows 2000 Device Driver Book”. Under
Behavior of DPC’s, in chapter 3 they say: “The DPC architecture prevents any
two DPCs from executing simultaneously, even on a multiprocessor machine.
Thus resources shared by different DPC routines do not need to worry about
synchronization.”

Haven’t reviewed the errata, can’t get to their site. However, on checking
Oney, Viscarola and Mason, and Decker and Newcomer, they all state the
opposite. So, in go the spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 11: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


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


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

Just to clarify something:

In point of fact, I corrected that error about multiprocessor DPCs in the
original galley proofs of the FIRST EDITION of the NT Driver Book – before
it ever went to press. Alas, the delightful production folks at Prentice
Hall never bothered to include my changes in the text of the book. On
successive printings, the error continued to appear.

I had planned on rewriting much of the book for its second edition.
Unfortunately, Prentice Hall and I couldn’t come to an agreement about a
schedule for the rewrite. (They were interested in “now” and I was pushing
for “correct.”) Exercising an ambiguous clause in the book contract, they
gave the job of preparing “The Windows 2000 Device Driver Book” to Mr.Lozano
and didn’t allow me to participate in any way whatsoever in the project.
(Indeed, to this day, I have never received so much as a piece of email from
Jeff Lozano.) So, once again, the necessary corrections didn’t happen.

In any event, my deepest apologies to those of you who have run into
problems because of this error.

The truth is that, yes indeed, multiple DPCs can run simultaneously on
multiprocessor boxes. So, be sure to use spinlocks or interlocked
instructions to guarantee the safety of any resources that might be shared
for write-access by those DPCs.

And now Little, Oney, Viscarola and Mason, Decker and Newcomer, AND Baker
are all saying the same thing… :wink:

Regards,
Art Baker

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary Little
Sent: Monday, September 24, 2001 1:32 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Yeah … and Little says the opposite of Baker/Lozano, as well. And that
comes from three years of getting screwed by multiple CPUs running the same
DPC, multiple times.

:slight_smile:

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Marc Reinig [mailto:xxxxx@pacbell.net]
Sent: Monday, September 24, 2001 9:31 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I got this from Baker/Lozano, “The Windows 2000 Device Driver Book”. Under
Behavior of DPC’s, in chapter 3 they say: “The DPC architecture prevents any
two DPCs from executing simultaneously, even on a multiprocessor machine.
Thus resources shared by different DPC routines do not need to worry about
synchronization.”

Haven’t reviewed the errata, can’t get to their site. However, on checking
Oney, Viscarola and Mason, and Decker and Newcomer, they all state the
opposite. So, in go the spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 11: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


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


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


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

Gosh, and I’m not even PUBLISHED!!!

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Art Baker [mailto:xxxxx@nfr.com]
Sent: Monday, September 24, 2001 1:05 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Just to clarify something:

In point of fact, I corrected that error about multiprocessor DPCs in the
original galley proofs of the FIRST EDITION of the NT Driver Book – before
it ever went to press. Alas, the delightful production folks at Prentice
Hall never bothered to include my changes in the text of the book. On
successive printings, the error continued to appear.

I had planned on rewriting much of the book for its second edition.
Unfortunately, Prentice Hall and I couldn’t come to an agreement about a
schedule for the rewrite. (They were interested in “now” and I was pushing
for “correct.”) Exercising an ambiguous clause in the book contract, they
gave the job of preparing “The Windows 2000 Device Driver Book” to Mr.Lozano
and didn’t allow me to participate in any way whatsoever in the project.
(Indeed, to this day, I have never received so much as a piece of email from
Jeff Lozano.) So, once again, the necessary corrections didn’t happen.

In any event, my deepest apologies to those of you who have run into
problems because of this error.

The truth is that, yes indeed, multiple DPCs can run simultaneously on
multiprocessor boxes. So, be sure to use spinlocks or interlocked
instructions to guarantee the safety of any resources that might be shared
for write-access by those DPCs.

And now Little, Oney, Viscarola and Mason, Decker and Newcomer, AND Baker
are all saying the same thing… :wink:

Regards,
Art Baker

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary Little
Sent: Monday, September 24, 2001 1:32 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Yeah … and Little says the opposite of Baker/Lozano, as well. And that
comes from three years of getting screwed by multiple CPUs running the same
DPC, multiple times.

:slight_smile:

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Marc Reinig [mailto:xxxxx@pacbell.net]
Sent: Monday, September 24, 2001 9:31 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I got this from Baker/Lozano, “The Windows 2000 Device Driver Book”. Under
Behavior of DPC’s, in chapter 3 they say: “The DPC architecture prevents any
two DPCs from executing simultaneously, even on a multiprocessor machine.
Thus resources shared by different DPC routines do not need to worry about
synchronization.”

Haven’t reviewed the errata, can’t get to their site. However, on checking
Oney, Viscarola and Mason, and Decker and Newcomer, they all state the
opposite. So, in go the spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
> Sent: Sunday, September 23, 2001 11: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


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


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


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


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

“Art Baker” wrote in message news:xxxxx@ntdev…
>
> it ever went to press. Alas, the delightful production folks at Prentice
> Hall never bothered to include my changes in the text of the book. On
>
>…
>
> And now Little, Oney, Viscarola and Mason, Decker and Newcomer, AND Baker
> are all saying the same thing… :wink:
>

Shall we all hold hands and sing? “Kumbaya, m’Lord…”

While I may disagree on a number of things with Mr. Baker, I can attest to
the fact that the production folks at Prentice Hall suck. How would I know
this? Well, Prentice Hall and MacMillan Technical Publishing (who published
our book) are all part of the same “family”. I strongly suspect, though I
do not know for certain, that they share production staffs.

From personal experience, I can tell you that the production team that did
our book completely, totally, and globally SUCKed. In fact, to merely say
that they SUCKed does not come even close to the conveying the utter
carelessness, disregard, and stupidity that they demonstrated on multiple
occaisions. And I’m being generous here.

If it hadn’t been for the extrodinary personal efforts of our Executive
Editor – a level at MacMillan that almost never gets involved in anything
so mundane as book production – the production on our book would have been
VERY seriously screwed up. And, as it was, we weren’t all that happy with
what came out.

Back to work,

Peter
OSR

Moral of the story: Pick your publisher carefully. Negotiate the contract
skillfully. Work with an Executive Editor (or at least an Acquisitons
Editor) that you really feel like you can trust and who’ll got to bat for
you. Keep all copyrights. Use the smoothness of your contract negotiations
as an indicator for how well they will work with you in the future. If the
contract negotiations don’t go well, find another publisher. Finally,
threaten to fall on your sword, publically urinate on and disown the book,
and call your lawyers if you really hate the final version of the book that
emerges.


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

> I was burned by this one on my first driver. The hardware was quick to

generate interrupts, and I would at times (right off the bat, actually)
get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR.

No need of doing this.
The correct DpcForIsr implementation must tolerate multiple ISRs from the
same device interrupting itself. It must also tolerate running several
instances of itself on several CPUs.

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

Ah! The joys of publishing. ;=)

Thanks all again.

Marc Reinig
System Solutions

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

In point of fact, I corrected that error about multiprocessor DPCs in the
original galley proofs of the FIRST EDITION of the NT Driver Book – before
it ever went to press. Alas, the delightful production folks at Prentice
Hall never bothered to include my changes in the text of the book. On
successive printings, the error continued to appear.

I had planned on rewriting much of the book for its second edition.
Unfortunately, Prentice Hall and I couldn’t come to an agreement about a
schedule for the rewrite. (They were interested in “now” and I was pushing
for “correct.”) Exercising an ambiguous clause in the book contract, they
gave the job of preparing “The Windows 2000 Device Driver Book” to Mr.Lozano
and didn’t allow me to participate in any way whatsoever in the project.
(Indeed, to this day, I have never received so much as a piece of email from
Jeff Lozano.) So, once again, the necessary corrections didn’t happen.

In any event, my deepest apologies to those of you who have run into
problems because of this error.

The truth is that, yes indeed, multiple DPCs can run simultaneously on
multiprocessor boxes. So, be sure to use spinlocks or interlocked
instructions to guarantee the safety of any resources that might be shared
for write-access by those DPCs.

And now Little, Oney, Viscarola and Mason, Decker and Newcomer, AND Baker
are all saying the same thing… :wink:

Regards,
Art Baker

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary Little
Sent: Monday, September 24, 2001 1:32 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Yeah … and Little says the opposite of Baker/Lozano, as well. And that
comes from three years of getting screwed by multiple CPUs running the same
DPC, multiple times.

:slight_smile:

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Marc Reinig [mailto:xxxxx@pacbell.net]
Sent: Monday, September 24, 2001 9:31 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I got this from Baker/Lozano, “The Windows 2000 Device Driver Book”. Under
Behavior of DPC’s, in chapter 3 they say: “The DPC architecture prevents any
two DPCs from executing simultaneously, even on a multiprocessor machine.
Thus resources shared by different DPC routines do not need to worry about
synchronization.”

Haven’t reviewed the errata, can’t get to their site. However, on checking
Oney, Viscarola and Mason, and Decker and Newcomer, they all state the
opposite. So, in go the spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 11: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


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


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


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


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

Yup, that’s what Little’s Device Driver book says … :slight_smile:

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Monday, September 24, 2001 9:58 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually)
get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR.

No need of doing this.
The correct DpcForIsr implementation must tolerate multiple ISRs from the
same device interrupting itself. It must also tolerate running several
instances of itself on several CPUs.

Max


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

Art,

What some people do is to have a book’s web site and an errata file in
there. A reference in the preface to the web site is enough, and after a few
interactions the readers learn fast where the errata is. For example, take a
look at http://www.cs.indiana.edu/eopl for the web page of Friedman, Wand
and Haynes’s book “Essentials of Programming Languages”, which I use in my
courses. Or you can look at http://theory.lcs.mit.edu for the web page of
Cormen, Leiserson and Rivest’s “Introduction to Algorithms”, which I also
use in my courses. The idea is to supplement the publishers’ mechanisms with
faster access to up to date information, including errata and programming
bugs. Works well in the academic world, I wonder if it would work out here
too.

Alberto.

-----Original Message-----
From: Art Baker [mailto:xxxxx@nfr.com]
Sent: Monday, September 24, 2001 4:05 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Just to clarify something:

In point of fact, I corrected that error about multiprocessor DPCs in the
original galley proofs of the FIRST EDITION of the NT Driver Book – before
it ever went to press. Alas, the delightful production folks at Prentice
Hall never bothered to include my changes in the text of the book. On
successive printings, the error continued to appear.

I had planned on rewriting much of the book for its second edition.
Unfortunately, Prentice Hall and I couldn’t come to an agreement about a
schedule for the rewrite. (They were interested in “now” and I was pushing
for “correct.”) Exercising an ambiguous clause in the book contract, they
gave the job of preparing “The Windows 2000 Device Driver Book” to Mr.Lozano
and didn’t allow me to participate in any way whatsoever in the project.
(Indeed, to this day, I have never received so much as a piece of email from
Jeff Lozano.) So, once again, the necessary corrections didn’t happen.

In any event, my deepest apologies to those of you who have run into
problems because of this error.

The truth is that, yes indeed, multiple DPCs can run simultaneously on
multiprocessor boxes. So, be sure to use spinlocks or interlocked
instructions to guarantee the safety of any resources that might be shared
for write-access by those DPCs.

And now Little, Oney, Viscarola and Mason, Decker and Newcomer, AND Baker
are all saying the same thing… :wink:

Regards,
Art Baker

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary Little
Sent: Monday, September 24, 2001 1:32 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Yeah … and Little says the opposite of Baker/Lozano, as well. And that
comes from three years of getting screwed by multiple CPUs running the same
DPC, multiple times.

:slight_smile:

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Marc Reinig [mailto:xxxxx@pacbell.net]
Sent: Monday, September 24, 2001 9:31 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I got this from Baker/Lozano, “The Windows 2000 Device Driver Book”. Under
Behavior of DPC’s, in chapter 3 they say: “The DPC architecture prevents any
two DPCs from executing simultaneously, even on a multiprocessor machine.
Thus resources shared by different DPC routines do not need to worry about
synchronization.”

Haven’t reviewed the errata, can’t get to their site. However, on checking
Oney, Viscarola and Mason, and Decker and Newcomer, they all state the
opposite. So, in go the spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware was quick to
generate interrupts, and I would at times (right off the bat, actually) get
a DPC running on each processor, merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the DPC rather
than at the end of the ISR. While this worked fine for the driver, it
played havoc with the buggy PCI core we were using at the time. The poor
hardware guys were tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system right now for the
very purpose of testing my drivers in a multi-processor environment. At
least one seminar teacher strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a multi-threaded
application as well, you may very well find some application bugs while you
are at it.

-Evan Hillman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
Sent: Sunday, September 23, 2001 11: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


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


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


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


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

Wow, sorry Art, didn’t realize what a horror show you were having with
your publisher.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Art Baker
Sent: Monday, September 24, 2001 4:05 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Just to clarify something:

In point of fact, I corrected that error about multiprocessor
DPCs in the original galley proofs of the FIRST EDITION of
the NT Driver Book – before it ever went to press. Alas, the
delightful production folks at Prentice Hall never bothered
to include my changes in the text of the book. On successive
printings, the error continued to appear.

I had planned on rewriting much of the book for its second
edition. Unfortunately, Prentice Hall and I couldn’t come to
an agreement about a schedule for the rewrite. (They were
interested in “now” and I was pushing for “correct.”)
Exercising an ambiguous clause in the book contract, they
gave the job of preparing “The Windows 2000 Device Driver
Book” to Mr.Lozano and didn’t allow me to participate in any
way whatsoever in the project. (Indeed, to this day, I have
never received so much as a piece of email from Jeff Lozano.)
So, once again, the necessary corrections didn’t happen.

In any event, my deepest apologies to those of you who have
run into problems because of this error.

The truth is that, yes indeed, multiple DPCs can run
simultaneously on multiprocessor boxes. So, be sure to use
spinlocks or interlocked instructions to guarantee the safety
of any resources that might be shared for write-access by those DPCs.

And now Little, Oney, Viscarola and Mason, Decker and
Newcomer, AND Baker are all saying the same thing… :wink:

Regards,
Art Baker

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary Little
Sent: Monday, September 24, 2001 1:32 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Yeah … and Little says the opposite of Baker/Lozano, as
well. And that comes from three years of getting screwed by
multiple CPUs running the same DPC, multiple times.

:slight_smile:

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com

-----Original Message-----
From: Marc Reinig [mailto:xxxxx@pacbell.net]
Sent: Monday, September 24, 2001 9:31 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

I got this from Baker/Lozano, “The Windows 2000 Device Driver
Book”. Under Behavior of DPC’s, in chapter 3 they say: “The
DPC architecture prevents any two DPCs from executing
simultaneously, even on a multiprocessor machine. Thus
resources shared by different DPC routines do not need to
worry about synchronization.”

Haven’t reviewed the errata, can’t get to their site.
However, on checking Oney, Viscarola and Mason, and Decker
and Newcomer, they all state the opposite. So, in go the
spinlocks ;=)

Thanks all,

Marc Reinig
System Solutions

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Evan Hillman
Sent: Monday, September 24, 2001 8:24 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

Marc,

I was burned by this one on my first driver. The hardware
was quick to generate interrupts, and I would at times (right
off the bat, actually) get a DPC running on each processor,
merrily stepping all over each other.

I fixed it by simply re-enabling interrupts at the end of the
DPC rather than at the end of the ISR. While this worked
fine for the driver, it played havoc with the buggy PCI core
we were using at the time. The poor hardware guys were
tearing their hair out for about two weeks.

As a side note: I am assembling a dual-processor system
right now for the very purpose of testing my drivers in a
multi-processor environment. At least one seminar teacher
strongly recommends testing on a system with the
more-the-merrier number of CPUs.

And, as an added bonus, if your company is producing a
multi-threaded application as well, you may very well find
some application bugs while you are at it.

-Evan Hillman

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Marc Reinig
> Sent: Sunday, September 23, 2001 11: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


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


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


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


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

Some months ago I even sent a logic description of such DPC here.

----- Original Message -----
From: “Gary Little”
To: “NT Developers Interest List”
Sent: Tuesday, September 25, 2001 1:48 AM
Subject: [ntdev] Re: Deferred Procedure Call WindowsNT

> Yup, that’s what Little’s Device Driver book says … :slight_smile:
>
> Gary G. Little
> Staff Engineer
> Broadband Storage, Inc.
> xxxxx@broadstor.com
>
> -----Original Message-----
> From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
> Sent: Monday, September 24, 2001 9:58 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: Deferred Procedure Call WindowsNT
>
> > I was burned by this one on my first driver. The hardware was quick to
> > generate interrupts, and I would at times (right off the bat, actually)
> get
> > a DPC running on each processor, merrily stepping all over each other.
> >
> > I fixed it by simply re-enabling interrupts at the end of the DPC rather
> > than at the end of the ISR.
>
> No need of doing this.
> The correct DpcForIsr implementation must tolerate multiple ISRs from the
> same device interrupting itself. It must also tolerate running several
> instances of itself on several CPUs.
>
> Max
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@broadstor.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> 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

> schedule for the rewrite. (They were interested in “now” and I was pushing

for “correct…”) Exercising …
Well, this disease don’t just affect books ABOUT software …

-DH


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

I would like to thank all of you for helping me.

Thank you once again.

Regards
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