RE: Re: Efficient way of "sharing" different buffers from k

Hi everyone,

I dont think you should consider this memory area as shared memory but as a simple storage area. Your servicing driver would then be a storage driver fort this particular storage area. Other system components would read or write to this area by sending IRM_MJ_READ and IRM_MJ_WRITE IRPs to the servicing driver.

This approach has multiple advantages. Firstly, all read and write operations are centralized in the two dispatch-routines and consequently, synchronization is made much easier. Secondly, the memory area address and the locks used to synchronize access are private to the servicing driver. Client drivers do not need these informations to perform read or write operations. This is safer.

To synchronize access you can use ERESOURCE or EX_PUSH_LOCK. These locks can be held as shared (read operations) or as exclusive (write operations). Note that an ERESOURCE lock can be held recursively while an EX_PUSH_LOCK lock cannot.

For multiple buffers, you can use IOCTL requests with one IOCTL code for each buffer read and write operation.

Shared memory is implemented by the OS using section objects, but sections are primarily used to share memory between processes.