Synchronization issue

Hi, All!

My question is how can I synchronize memory access from my filter drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiprocessor machine?

Thanks in advance,
Mikhail.

Use spin locks: initialize in DriverEntry of the first driver, use in
dispatch or completion. This is probably the single solution if both
functions write to the memory.

If you have a special case (one writer, one reader running <dispatch_level>and want faster execution, there are other possibilities: mutexes or fast
mutextes or events can be used.

Occasionally ExInterlockedXxx functions can be used.

Joze

-----Original Message-----
From: Mikhail [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 4:32 PM
To: NT Developers Interest List
Subject: [ntdev] Synchronization issue

Hi, All!

My question is how can I synchronize memory access from my filter drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiprocessor machine?

Thanks in advance,
Mikhail.


You are currently subscribed to ntdev as: xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com</dispatch_level>

Joze,
Thanks a lot for your reply,
I just want to clarify how can I synchronize with callback routine that is called from SCSI miniport driver at DIRQL that is higher, than DISPATCH_LEVEL
Thanks a lot,
Mikhail.

Joze Fabcic wrote:Use spin locks: initialize in DriverEntry of the first driver, use in
dispatch or completion. This is probably the single solution if both
functions write to the memory.

If you have a special case (one writer, one reader running and want faster execution, there are other possibilities: mutexes or fast
mutextes or events can be used.

Occasionally ExInterlockedXxx functions can be used.

Joze

-----Original Message-----
From: Mikhail [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 4:32 PM
To: NT Developers Interest List
Subject: [ntdev] Synchronization issue

Hi, All!

My question is how can I synchronize memory access from my filter drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiprocessor machine?

Thanks in advance,
Mikhail.


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


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

---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online

IF you have the interrupt object the miniport driver is using you can
use KeSynchronizeExecution. However this blocks the interrupt from
being delivered so you don’t want to spend a lot of time in that
callback routine.

Otherwise the typical solution is to use the DIRQL callback to queue a
DPC and then use spinlocks in the DPC to synchronize with the filter
driver’s dispatch routine.

-p

-----Original Message-----
From: Mikhail [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 7:32 AM
To: NT Developers Interest List

Hi, All!

My question is how can I synchronize memory access from my filter
drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiprocessor machine?

Thanks in advance,
Mikhail.


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

Note that neither spinlocks nor mutex/fast-mutex/event should be used to
synchronize with a routine at DIRQL.

The interlocked exchange functions, on the other hand, work just ducky.

-p

-----Original Message-----
From: Joze Fabcic [mailto:xxxxx@hermes.si]
Sent: Thursday, March 13, 2003 7:47 AM
To: NT Developers Interest List

Use spin locks: initialize in DriverEntry of the first driver, use in
dispatch or completion. This is probably the single solution if both
functions write to the memory.

If you have a special case (one writer, one reader running
<dispatch_level and want faster execution there are other>possibilities: mutexes or fast mutextes or events can be used.

Occasionally ExInterlockedXxx functions can be used.

Joze

-----Original Message-----
From: Mikhail [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 4:32 PM
To: NT Developers Interest List
Subject: [ntdev] Synchronization issue

Hi, All!

My question is how can I synchronize memory access from my filter
drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiprocessor machine?

Thanks in advance,
Mikhail.


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


You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</dispatch_level>

Is it not already synchronized owing to the IRQL?

I am amazed that there are still folks doing this in a standard
miniport…

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mikhail
Sent: Thursday, March 13, 2003 7:32 AM
To: NT Developers Interest List
Subject: [ntdev] Synchronization issue

Hi, All!

My question is how can I synchronize memory access from my filter
drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiprocessor machine?

Thanks in advance,
Mikhail.


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

To Synchronize between routines where one is running @ DIRQL & other at
below level, use KeSynchronizeExecution( ).

-±±±±±±±±±±±±±±±±±±+
We are what we repeatedly do.
Excellence, then is not an act. But a habit.
-±±±±±±±±±±±±±±±±±±+
-----Original Message-----
From: Mikhail S [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 9:38 PM
Subject: RE: Synchronization issue

Joze,
Thanks a lot for your reply,
I just want to clarify how can I synchronize with callback routine that
is called from SCSI miniport driver at DIRQL that is higher, than
DISPATCH_LEVEL
Thanks a lot,
Mikhail.

Joze Fabcic wrote:
Use spin locks: initialize in DriverEntry of the first driver, use in
dispatch or completion. This is probably the single solution if both
functions write to the memory.

If you have a special case (one writer, one reader running and want
faster execution, there are other possibilities: mutexes or fast
mutextes or events can be used.

Occasionally ExInterlockedXxx functions can be used.

Joze

-----Original Message-----
From: Mikhail [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 4:32 PM
To: NT Developers Interest List
Subject: [ntdev] Synchronization issue

Hi, All!

My question is how can I synchronize memory access from my filter
drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiproces! sor machine?

Thanks in advnce,
Mikhail.


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


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

Do you Yahoo!?
Yahoo! Web Hosting - establish your business online

Oh? And just how does one do that when one is in a SCSI minport and
KeSynchronizeExecution is not defined nor avaialable?


Gary G. Little
Have Computer, Will Travel …
909-698-3191
909-551-2105
http://www.wd-3.com

“Sathyanarayanan Srinivasan” wrote in
message news:xxxxx@ntdev…

To Synchronize between routines where one is running @ DIRQL & other at
below level, use KeSynchronizeExecution( ).

-±±±±±±±±±±±±±±±±±±+
We are what we repeatedly do.
Excellence, then is not an act. But a habit.
-±±±±±±±±±±±±±±±±±±+
-----Original Message-----
From: Mikhail S [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 9:38 PM
Subject: RE: Synchronization issue

Joze,
Thanks a lot for your reply,
I just want to clarify how can I synchronize with callback routine that
is called from SCSI miniport driver at DIRQL that is higher, than
DISPATCH_LEVEL
Thanks a lot,
Mikhail.

Joze Fabcic wrote:
Use spin locks: initialize in DriverEntry of the first driver, use in
dispatch or completion. This is probably the single solution if both
functions write to the memory.

If you have a special case (one writer, one reader running and want
faster execution, there are other possibilities: mutexes or fast
mutextes or events can be used.

Occasionally ExInterlockedXxx functions can be used.

Joze

-----Original Message-----
From: Mikhail [mailto:xxxxx@yahoo.com]
Sent: Thursday, March 13, 2003 4:32 PM
To: NT Developers Interest List
Subject: [ntdev] Synchronization issue

Hi, All!

My question is how can I synchronize memory access from my filter
drivers’
dispatsh routines and from my filter drivers’ callback routine that is
called by underlying miniport driver at the DIRQL level on a
multiproces! sor machine?

Thanks in advnce,
Mikhail.


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


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

Do you Yahoo!?
Yahoo! Web Hosting - establish your business online

I have developed a filter driver for in real-time hard disk
ciphering/unciphering and I have a synchronization problem. I filter the
main dispatch driver’s routines (IRP_MJ_READ and IRP_MJ_WRITE) in order to
cipher/decipher data every time a set of disk sectors is written/read.
Besides, I have a system thread which accomplishes the initial whole disk
ciphering at the same time as Windows works normally. I have been using
KEVENT’s for establishing the needed synchronization between these two
process (to avoiding the risk of not knowing if a given sector is ciphered
or not) and I have some problems. Then I’ve been using FAST_MUTEX and
ERESOURCE (the “Lite” version of them). I think that SPIN_LOCK’s are
unsuitable too. Which is the most suitable synchronization mechanism for
this task? The driver is desinged for W2K/XP.

Best regards,

Jose Vicente.

Since the disk driver’s dispatch routines are usually callable
from DISPATCH_LEVEL, it would be good to preserve such a tradition.
So, it is better to use spinlocks for synchronization here.
Since you cannot do anything complex while holding a spinlock, I
would suggest to use the “transition” state semantics while doing slow
operations on the data without holding a lock. After the operation is
complete, grab the lock and make all necessary updates to reflect the
operation completion.

Max

----- Original Message -----
From: “Jose Vicente Sanchez Ortega”
To: “NT Developers Interest List”
Sent: Saturday, April 12, 2003 3:27 PM
Subject: [ntdev] Synchronization issue

> I have developed a filter driver for in real-time hard disk
> ciphering/unciphering and I have a synchronization problem. I filter
the
> main dispatch driver’s routines (IRP_MJ_READ and IRP_MJ_WRITE) in
order to
> cipher/decipher data every time a set of disk sectors is
written/read.
> Besides, I have a system thread which accomplishes the initial whole
disk
> ciphering at the same time as Windows works normally. I have been
using
> KEVENT’s for establishing the needed synchronization between these
two
> process (to avoiding the risk of not knowing if a given sector is
ciphered
> or not) and I have some problems. Then I’ve been using FAST_MUTEX
and
> ERESOURCE (the “Lite” version of them). I think that SPIN_LOCK’s are
> unsuitable too. Which is the most suitable synchronization mechanism
for
> this task? The driver is desinged for W2K/XP.
>
> Best regards,
>
> Jose Vicente.
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

Max:

Thank you very much for your answer. I don’t understand the las paragraph.
What can you say with “transition state semantics”?

Jose Vicente.

-----Mensaje original-----
De: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]En nombre de Maxim S. Shatskih
Enviado el: sabado, 12 de abril de 2003 22:02
Para: NT Developers Interest List
Asunto: [ntdev] Re: Synchronization issue

Since the disk driver’s dispatch routines are usually callable
from DISPATCH_LEVEL, it would be good to preserve such a tradition.
So, it is better to use spinlocks for synchronization here.
Since you cannot do anything complex while holding a spinlock, I
would suggest to use the “transition” state semantics while doing slow
operations on the data without holding a lock. After the operation is
complete, grab the lock and make all necessary updates to reflect the
operation completion.

Max

----- Original Message -----
From: “Jose Vicente Sanchez Ortega”
To: “NT Developers Interest List”
Sent: Saturday, April 12, 2003 3:27 PM
Subject: [ntdev] Synchronization issue

> I have developed a filter driver for in real-time hard disk
> ciphering/unciphering and I have a synchronization problem. I filter
the
> main dispatch driver’s routines (IRP_MJ_READ and IRP_MJ_WRITE) in
order to
> cipher/decipher data every time a set of disk sectors is
written/read.
> Besides, I have a system thread which accomplishes the initial whole
disk
> ciphering at the same time as Windows works normally. I have been
using
> KEVENT’s for establishing the needed synchronization between these
two
> process (to avoiding the risk of not knowing if a given sector is
ciphered
> or not) and I have some problems. Then I’ve been using FAST_MUTEX
and
> ERESOURCE (the “Lite” version of them). I think that SPIN_LOCK’s are
> unsuitable too. Which is the most suitable synchronization mechanism
for
> this task? The driver is desinged for W2K/XP.
>
> Best regards,
>
> Jose Vicente.
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com


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

Your objects must have the “operation is in progress” state. To
initiate the operation, grab the spinlock, do the necessary updates,
set the object to this “transition” state, and release the lock. The
operation itself will be running without a lock.
At operation completion, grab the lock, go the necessary updates to
mark the fact of the completion, and release the lock.

This is just a concept, not a step-by-step way of writing code.

Max

----- Original Message -----
From: “Jose Vicente Sanchez Ortega”
To: “NT Developers Interest List”
Sent: Sunday, April 13, 2003 5:45 PM
Subject: [ntdev] Re: Synchronization issue

> Max:
>
> Thank you very much for your answer. I don’t understand the las
paragraph.
> What can you say with “transition state semantics”?
>
> Jose Vicente.
>
>
> -----Mensaje original-----
> De: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]En nombre de Maxim S.
Shatskih
> Enviado el: sabado, 12 de abril de 2003 22:02
> Para: NT Developers Interest List
> Asunto: [ntdev] Re: Synchronization issue
>
>
> Since the disk driver’s dispatch routines are usually callable
> from DISPATCH_LEVEL, it would be good to preserve such a tradition.
> So, it is better to use spinlocks for synchronization here.
> Since you cannot do anything complex while holding a spinlock, I
> would suggest to use the “transition” state semantics while doing
slow
> operations on the data without holding a lock. After the operation
is
> complete, grab the lock and make all necessary updates to reflect
the
> operation completion.
>
> Max
>
> ----- Original Message -----
> From: “Jose Vicente Sanchez Ortega”
> To: “NT Developers Interest List”
> Sent: Saturday, April 12, 2003 3:27 PM
> Subject: [ntdev] Synchronization issue
>
>
> > I have developed a filter driver for in real-time hard disk
> > ciphering/unciphering and I have a synchronization problem. I
filter
> the
> > main dispatch driver’s routines (IRP_MJ_READ and IRP_MJ_WRITE) in
> order to
> > cipher/decipher data every time a set of disk sectors is
> written/read.
> > Besides, I have a system thread which accomplishes the initial
whole
> disk
> > ciphering at the same time as Windows works normally. I have been
> using
> > KEVENT’s for establishing the needed synchronization between these
> two
> > process (to avoiding the risk of not knowing if a given sector is
> ciphered
> > or not) and I have some problems. Then I’ve been using FAST_MUTEX
> and
> > ERESOURCE (the “Lite” version of them). I think that SPIN_LOCK’s
are
> > unsuitable too. Which is the most suitable synchronization
mechanism
> for
> > this task? The driver is desinged for W2K/XP.
> >
> > Best regards,
> >
> > Jose Vicente.
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@secuware.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com