From: Mohit Gupta on
I have a dedicated memory (non-paged memory) which is used by interrupt
routines to write data and PASSIVE_LEVEL system thread to read data from

Now I want to synchronise read and writes. Can you please advise how can I
achieve that in Multiple processor (MP) system
From: Pavel A. on
Synchronization works on the highest level of all players.
So, if one of them runs at DIRQL, you've got to use
KeAcquireInterruptSpinLock or KeSynchronizeExecution.

Regards,
-- pa

"Mohit Gupta" <MohitGupta(a)discussions.microsoft.com> wrote in message
news:CEA577E1-E507-485E-BACE-B80B4C4E471F(a)microsoft.com...
> I have a dedicated memory (non-paged memory) which is used by interrupt
> routines to write data and PASSIVE_LEVEL system thread to read data from
>
> Now I want to synchronise read and writes. Can you please advise how can I
> achieve that in Multiple processor (MP) system

From: Simon Richter on
Hi,

On 2010年06月18日 09:17, Mohit Gupta wrote:

> I have a dedicated memory (non-paged memory) which is used by interrupt
> routines to write data and PASSIVE_LEVEL system thread to read data from

> Now I want to synchronise read and writes. Can you please advise how can I
> achieve that in Multiple processor (MP) system

From your other post, I gather that you have a
single-writer-single-reader use case. In that case, I'd advise to use a
ring buffer for transporting the actual data, and a notification
mechanism by which the writer can wake up the reader when data is available.

The ring buffer can be accessed without locks, as each thread will only
increase one of the pointers, and read the other; loss of
synchronisation here is not harmful as long as the notification
mechanism makes sure that the updated "write pointer" is visible to the
reader when it is woken up, so it does not go back to sleep before it
sees the update.

You will need to take care that the pointers are suitably aligned that
they can be atomically read from and written to.

You will lose events when the buffer is full, but this cannot be
avoided, as the interrupt handler cannot allocate memory.

Simon