Re: SHaring buffer from kernel to applications-help!!!



Seriously, think about this. Sharing memory is a bad idea in most cases.
Audio does not have the bandwidth to justify it, versus the standard
read/write/IOCTL calls. With shared memory you have a lot of problems:

1. No good way to get notification when the application you are
sharing with dies.
2. A number of challenges on synchronizing access to the data,
including that the sync calls can be higher overhead than doing it with the
standard calls.
3. Problems when you want to expand or contract the buffer area.

I've worked on projects where we used shared memory (delivering streaming
video at HDTV quality), and getting this stuff right was a pain in the ass.
The initial work by experienced developers was handed over to senior people
for tuning, this initial work had been deemed shippable quality. When the
senior people went through it with a full review not a single piece of the
original remained, since there were that many bugs. This was not that the
original developers were bad, but that a full scale deliver data such that
you needed shared memory is that hard.

Since that project I have twice ripped out work by other consultants who
used shared memory, and replaced it with standard calls. In each case the
code was smaller and faster than trying to get shared memory correct.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply



<arijit.p@xxxxxxxxx> wrote in message
news:1164282758.108053.113760@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All,

I am writing a pseudo miniport-audio driver(MSVAD samples). I need to
read audio data from application and for that my driver is allocating a
buffer and sharing it with application (outlined in
http://www.osronline.com/article.cfm?id=39). I am following the
approach outlined in the last section, sharing buffer from driver to
application. Hope I am doing the right thing. I have few more questions
in this regard:-

1) How do i create a driver name so that I can open it from my
application and read/write from the shared buffer? (when you want to
open a device, you need device name). I tried doing that using
IoCreateSymbolicLink() in DriverEntry(), but it crashed whole system.
Is this the correct approach? I heard for mini-port driver it is not
possible (in that case i hav to handle all IRPs and have to write a bus
driver). Please help.

2) Do I need to overwrite the following IRPs in DriverEntry(). Miniport
drivers(MSVAD) doesn't handle IRPs, all are being handled by port
driver (wavecyclic).

DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
DispatchClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
DispatchDevCtrl;
DriverObject->MajorFunction[IRP_MJ_READ] = DispatchRead;
DriverObject->DriverUnload = Unload;

Can we do that?

3) Do you have any idea of device extensions? Can we use that for
reading and writing from application?

Please help me. I am really confused and not getting any help around.

Thanks a lot!

-paul
arijit.p@xxxxxxxxx wrote:
Hi All,

I am writing a pseudo miniport-audio driver(MSVAD samples). I need to
read audio data from application and for that my driver is allocating a
buffer and sharing it with application (outlined in
http://www.osronline.com/article.cfm?id=39). I am following the
approach outlined in the last section, sharing buffer from driver to
application. Hope I am doing the right thing. I have few more questions
in this regard:-

1) How do i create a driver name so that I can open it from my
application and read/write from the shared buffer? (when you want to
open a device, you need device name). I tried doing that using
IoCreateSymbolicLink() in DriverEntry(), but it crashed whole system.
Is this the correct approach? I heard for mini-port driver it is not
possible (in that case i hav to handle all IRPs and have to write a bus
driver). Please help.

2) Do I need to overwrite the following IRPs in DriverEntry(). Miniport
drivers(MSVAD) doesn't handle IRPs, all are being handled by port
driver (wavecyclic).

DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
DispatchClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
DispatchDevCtrl;
DriverObject->MajorFunction[IRP_MJ_READ] = DispatchRead;
DriverObject->DriverUnload = Unload;

Can we do that?

3) Do you have any idea of device extensions? Can we use that for
reading and writing from application?

Please help me. I am really confused and not getting any help around.

Thanks a lot!

-paul



.



Relevant Pages

  • Re: Direct Copying To Share Memory In NDIS ProtocolReceive
    ... Application allocates large structured buffer with room for seveveral packets. ... Driver fills buffer with multiple packets and eventually completes the read IRP. ... This, or variations on this, should work for you withoug having to have shared memory and events that are not part of the standard I/O scheme. ... I am wondering if I can obviate much of the NDIS packet allocation by ...
    (microsoft.public.development.device.drivers)
  • Re: Direct Copying To Share Memory In NDIS ProtocolReceive
    ... Driver uses ... MmGetSystemAddressForMdlSafe to map buffer to kernel memory. ... multiple packets and eventually completes the read IRP. ... shared memory and events that are not part of the standard I/O scheme. ...
    (microsoft.public.development.device.drivers)
  • Re: Direct Copying To Share Memory In NDIS ProtocolReceive
    ... Driver uses ... MmGetSystemAddressForMdlSafe to map buffer to kernel memory. ... multiple packets and eventually completes the read IRP. ... shared memory and events that are not part of the standard I/O scheme. ...
    (microsoft.public.development.device.drivers)
  • Re: sharing memory with user and kernel
    ... handle the problems of the user mode application going away or the driver ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... the data in shared memory using CreateFileMapping and MapViewOfFile. ... working on a virtual mic driver and my ...
    (microsoft.public.development.device.drivers)
  • Re: sharing memory with user and kernel
    ... handle the problems of the user mode application going away or the driver ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... the data in shared memory using CreateFileMapping and MapViewOfFile. ... working on a virtual mic driver and my ...
    (microsoft.public.development.device.drivers)