Hi Guys,
I have a design related question.
Suppose I have a KMDF driver which has shared memory (mapped via MDL or whatever) with user mode. Memory sharing is not the issue here.
Also suppose that the driver moves chunks of data (fixed size) to the shared buffer during ISR called DPC routine.
This driver has three channels, each holding a separate shared buffer and each producing around 30-40 chunks per second. The chunks ate quite large - several MByte each.
Also,the project consists of both User and Kernel mode SW (driver + SDK) so I can do whatever I want in both.
It looks like I have two options to implement the “get_memory_chunk” flow from user to kernel mode
-
The usual mode - using ASYNC IOCTLs.
For each channel :
a. Implement parallel queue and some collection object for get_memory_chunk request. Upon receiving IOCTL in the driver, push the received request (if no chunks are ready) to the collection of requests.
b. When ISR scheduled DPC runs,another chunk is ready. Copy the chunk to shared buffer, pop (head or tail) the list of requests and complete the request, hence notifying the user mode that the chunk is ready. -
Using shared event
For each channel :
a. Implement shared event between user and kernel . In user mode there will be thread (for each channel) waiting on the event.
b. Don’t send any get_memory_chunk IOCTLs from user to kernel.
c. In kernel, during ISR scheduled DPC, copy the chunk to shared buffer and then signal user mode using the event that the chunk is ready.
The funny thing is that option 2 actually looks much better - you don’t have to worry about requests, timeouts, holding queues or power state changes.
The driver actually becomes a simply copy+notify machine.
But, isn’t it too good to be true ?
What do you guys think ?
10x
Sagi Bar