Synchronization of ISR routines

Hi alll,

My Win2000 driver have to control many of PCI cards.
How can I synchronize access to a shared resoruce for multiple instance of
ISR routine ?
For now, I uses KeSynchronizeExecution() but i’m not sure it is the right
way to do. Please advise.

I uses interrupt spinkock of the master card as the synchronization object.
Consider the following code if my ISR routine

My_ISR_Routine()
{

if ( pDeviceExtention->bCardMaster )
{
// Interrupt from the master card.
// Its interrupt spinlock is already held by Nt manager
AccessToSharedResource( pContext );
}
else
{
// Interrupts from other cards
// Try to acquire master card’s interrupt spin lock
KeSynchronizeExecution(
pCardMaster->pDeviceExtention->kInterruptOject, AccessToSharedResource,
pContext );
}


}

I have system frozen on KeSynchronizeExecution(), even with single CPU
machine.
What is wrong with my code ? Please advise.

Thanks for help,

QUANG

This is not a good design, so if you can find some other way to arrange
things you should consider doing so.

The deadlock could be a result of not noticing the restriction: ‘callers
of KeSynchronizeExecution must be running at IRQL <= DIRQL’. The
implication of that is that your master should have the HIGHEST IRQL
value. Note that there is no particular way to enforce that restriction
unless…

Perhaps a simpler approach, however one that illustrates why this is a
bad design, is to have all of your ISRs share the same interrupt
spinlock. Now they are all serialized. Your design puts you there
anyway, so why not?

Better would be to defer whatever AccessToSharedResource does to your
DPC routine, where a simple spinlock would be sufficient.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Quang Vu
Sent: Monday, October 24, 2005 4:21 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization of ISR routines

Hi alll,

My Win2000 driver have to control many of PCI cards.
How can I synchronize access to a shared resoruce for multiple instance
of
ISR routine ?
For now, I uses KeSynchronizeExecution() but i’m not sure it is the
right
way to do. Please advise.

I uses interrupt spinkock of the master card as the synchronization
object.
Consider the following code if my ISR routine

My_ISR_Routine()
{

if ( pDeviceExtention->bCardMaster )
{
// Interrupt from the master card.
// Its interrupt spinlock is already held by Nt manager
AccessToSharedResource( pContext );
}
else
{
// Interrupts from other cards
// Try to acquire master card’s interrupt spin lock
KeSynchronizeExecution(
pCardMaster->pDeviceExtention->kInterruptOject, AccessToSharedResource,

pContext );
}


}

I have system frozen on KeSynchronizeExecution(), even with single CPU
machine.
What is wrong with my code ? Please advise.

Thanks for help,

QUANG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

If at all possible, I would strongly suggest redesigning your hardware
to not share resources across the device functions. While getting this
running is somewhat trivial, you have other issues, specifically related
to device removal/disable and power operations.

What if the device which is card master is powered down and the other
function is in D0 and receives an interrupt? Or the opposite, where
both functions are powered off and the non bus master function is
powered up first and triggers an interrupt? What if the device which is
the bus master is disabled and the other functions are left in the
running state?

You are creating a cross tree dependency which the pnp manager does not
take care of for you and you will encounter some difficult
synchronization issues.

D

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Roddy, Mark
Sent: Monday, October 24, 2005 2:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Synchronization of ISR routines

This is not a good design, so if you can find some other way to arrange
things you should consider doing so.

The deadlock could be a result of not noticing the restriction: ‘callers
of KeSynchronizeExecution must be running at IRQL <= DIRQL’. The
implication of that is that your master should have the HIGHEST IRQL
value. Note that there is no particular way to enforce that restriction
unless…

Perhaps a simpler approach, however one that illustrates why this is a
bad design, is to have all of your ISRs share the same interrupt
spinlock. Now they are all serialized. Your design puts you there
anyway, so why not?

Better would be to defer whatever AccessToSharedResource does to your
DPC routine, where a simple spinlock would be sufficient.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Quang Vu
Sent: Monday, October 24, 2005 4:21 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization of ISR routines

Hi alll,

My Win2000 driver have to control many of PCI cards.
How can I synchronize access to a shared resoruce for multiple instance
of
ISR routine ?
For now, I uses KeSynchronizeExecution() but i’m not sure it is the
right
way to do. Please advise.

I uses interrupt spinkock of the master card as the synchronization
object.
Consider the following code if my ISR routine

My_ISR_Routine()
{

if ( pDeviceExtention->bCardMaster )
{
// Interrupt from the master card.
// Its interrupt spinlock is already held by Nt manager
AccessToSharedResource( pContext );
}
else
{
// Interrupts from other cards
// Try to acquire master card’s interrupt spin lock
KeSynchronizeExecution(
pCardMaster->pDeviceExtention->kInterruptOject, AccessToSharedResource,

pContext );
}


}

I have system frozen on KeSynchronizeExecution(), even with single CPU
machine.
What is wrong with my code ? Please advise.

Thanks for help,

QUANG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

More so. The single driver for several inter-dependent cards is not so
supported in Windows in fact. What is supported is a driver for each card, and
then the code (usually user mode) who ties them together. Look at, for
instance, DirectShow.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Roddy, Mark”
To: “Windows System Software Devs Interest List”
Sent: Tuesday, October 25, 2005 1:05 AM
Subject: RE: [ntdev] Synchronization of ISR routines

This is not a good design, so if you can find some other way to arrange
things you should consider doing so.

The deadlock could be a result of not noticing the restriction: ‘callers
of KeSynchronizeExecution must be running at IRQL <= DIRQL’. The
implication of that is that your master should have the HIGHEST IRQL
value. Note that there is no particular way to enforce that restriction
unless…

Perhaps a simpler approach, however one that illustrates why this is a
bad design, is to have all of your ISRs share the same interrupt
spinlock. Now they are all serialized. Your design puts you there
anyway, so why not?

Better would be to defer whatever AccessToSharedResource does to your
DPC routine, where a simple spinlock would be sufficient.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Quang Vu
Sent: Monday, October 24, 2005 4:21 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization of ISR routines

Hi alll,

My Win2000 driver have to control many of PCI cards.
How can I synchronize access to a shared resoruce for multiple instance
of
ISR routine ?
For now, I uses KeSynchronizeExecution() but i’m not sure it is the
right
way to do. Please advise.

I uses interrupt spinkock of the master card as the synchronization
object.
Consider the following code if my ISR routine

My_ISR_Routine()
{

if ( pDeviceExtention->bCardMaster )
{
// Interrupt from the master card.
// Its interrupt spinlock is already held by Nt manager
AccessToSharedResource( pContext );
}
else
{
// Interrupts from other cards
// Try to acquire master card’s interrupt spin lock
KeSynchronizeExecution(
pCardMaster->pDeviceExtention->kInterruptOject, AccessToSharedResource,

pContext );
}


}

I have system frozen on KeSynchronizeExecution(), even with single CPU
machine.
What is wrong with my code ? Please advise.

Thanks for help,

QUANG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Mark,

Now I know what I should do.

QUANG


“Roddy, Mark” wrote in message news:xxxxx@ntdev…
This is not a good design, so if you can find some other way to arrange
things you should consider doing so.

The deadlock could be a result of not noticing the restriction: ‘callers
of KeSynchronizeExecution must be running at IRQL <= DIRQL’. The
implication of that is that your master should have the HIGHEST IRQL
value. Note that there is no particular way to enforce that restriction
unless…

Perhaps a simpler approach, however one that illustrates why this is a
bad design, is to have all of your ISRs share the same interrupt
spinlock. Now they are all serialized. Your design puts you there
anyway, so why not?

Better would be to defer whatever AccessToSharedResource does to your
DPC routine, where a simple spinlock would be sufficient.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Quang Vu
Sent: Monday, October 24, 2005 4:21 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization of ISR routines

Hi alll,

My Win2000 driver have to control many of PCI cards.
How can I synchronize access to a shared resoruce for multiple instance
of
ISR routine ?
For now, I uses KeSynchronizeExecution() but i’m not sure it is the
right
way to do. Please advise.

I uses interrupt spinkock of the master card as the synchronization
object.
Consider the following code if my ISR routine

My_ISR_Routine()
{

if ( pDeviceExtention->bCardMaster )
{
// Interrupt from the master card.
// Its interrupt spinlock is already held by Nt manager
AccessToSharedResource( pContext );
}
else
{
// Interrupts from other cards
// Try to acquire master card’s interrupt spin lock
KeSynchronizeExecution(
pCardMaster->pDeviceExtention->kInterruptOject, AccessToSharedResource,

pContext );
}


}

I have system frozen on KeSynchronizeExecution(), even with single CPU
machine.
What is wrong with my code ? Please advise.

Thanks for help,

QUANG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

You should pay attention to the comments from Doron and Maxim as well.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Quang Vu
Sent: Tuesday, October 25, 2005 9:04 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Synchronization of ISR routines

Thanks Mark,

Now I know what I should do.

QUANG



“Roddy, Mark” wrote in message
news:xxxxx@ntdev…
This is not a good design, so if you can find some other way to arrange
things you should consider doing so.

The deadlock could be a result of not noticing the restriction: ‘callers
of KeSynchronizeExecution must be running at IRQL <= DIRQL’. The
implication of that is that your master should have the HIGHEST IRQL
value. Note that there is no particular way to enforce that restriction
unless…

Perhaps a simpler approach, however one that illustrates why this is a
bad design, is to have all of your ISRs share the same interrupt
spinlock. Now they are all serialized. Your design puts you there
anyway, so why not?

Better would be to defer whatever AccessToSharedResource does to your
DPC routine, where a simple spinlock would be sufficient.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Quang Vu
Sent: Monday, October 24, 2005 4:21 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization of ISR routines

Hi alll,

My Win2000 driver have to control many of PCI cards.
How can I synchronize access to a shared resoruce for multiple instance
of
ISR routine ?
For now, I uses KeSynchronizeExecution() but i’m not sure it is the
right
way to do. Please advise.

I uses interrupt spinkock of the master card as the synchronization
object.
Consider the following code if my ISR routine

My_ISR_Routine()
{

if ( pDeviceExtention->bCardMaster )
{
// Interrupt from the master card.
// Its interrupt spinlock is already held by Nt manager
AccessToSharedResource( pContext );
}
else
{
// Interrupts from other cards
// Try to acquire master card’s interrupt spin lock
KeSynchronizeExecution(
pCardMaster->pDeviceExtention->kInterruptOject, AccessToSharedResource,

pContext );
}


}

I have system frozen on KeSynchronizeExecution(), even with single CPU
machine.
What is wrong with my code ? Please advise.

Thanks for help,

QUANG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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