Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 4  
17 Feb 18 20:19
Michael Rolle
xxxxxx@rolle.name
Join Date: 27 Dec 2017
Posts To This List: 59
Are Dpcs and IRPs serialized?

Two questions here, one about Dpc and the other about IRP. (1) Can a driver have two CustomDpc functions running at the same time? I realize that since they run at DISPATCH_LEVEL, they will be serialized on the same processor. But what about different processors? My guess is that they are not serialized, and so can run concurrently on different processors. That would mean that the routines need to use some synchronization method to serialize access to critical data. But before I put this synchronization into the Dpc routines, I thought I'd see if the routines themselves run serially across all processors. (2) What happens when one user thread initiates IRP 1, and another thread initiates IRP 2 while IRP 1 is not yet completed? When is the driver's dispatch routine for IRP 2 called? Does the IoManager serialize the dispatch routine calls across all processors? I want to provide exclusive access to a shared device by having Acquire and Release IOCTLs. I plan to have the Acquire function post the IRP with DEVICE_BUSY if another Acquire is in effect, rather than put the calling thread in a wait state. It would be nice if the IOCTL dispatch calls run serially, so that I don't have to worry about synchronization issues.
  Message 2 of 4  
17 Feb 18 23:26
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11963
Are Dpcs and IRPs serialized?

On Feb 17, 2018, at 5:19 PM, xxxxx@rolle.name <xxxxx@lists.osr.com> wrote: > > Two questions here, one about Dpc and the other about IRP. > > (1) Can a driver have two CustomDpc functions running at the same time? I realize that since they run at DISPATCH_LEVEL, they will be serialized on the same processor. But what about different processors? > > My guess is that they are not serialized, and so can run concurrently on different processors. That would mean that the routines need to use some synchronization method to serialize access to critical data. Correct. You do have the option of forcing your DPC into a specific processor using KeSetTargetProcessorDpc. Whether that's more or less trouble than synchronization is debatable; most sync needs are pretty simple. > (2) What happens when one user thread initiates IRP 1, and another thread initiates IRP 2 while IRP 1 is not yet completed? When is the driver's dispatch routine for IRP 2 called? Does the IoManager serialize the dispatch routine calls across all processors? The I/O manager does no serialization at all. If the receiving driver happens to use StartIo or a KMDF serial queue, those will do serialization, but it's all inside the driver. > I want to provide exclusive access to a shared device by having Acquire and Release IOCTLs. I plan to have the Acquire function post the IRP with DEVICE_BUSY if another Acquire is in effect, rather than put the calling thread in a wait state. It would be nice if the IOCTL dispatch calls run serially, so that I don't have to worry about synchronization issues. Well, that's a trivially easy synchronization problem -- a simple InterlockedExchange would do it. ??? Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 3 of 4  
18 Feb 18 15:49
Mark Roddy
xxxxxx@gmail.com
Join Date: 25 Feb 2000
Posts To This List: 4090
Are Dpcs and IRPs serialized?

If you are using KMDF you can have KMDF impose the serialization you want for IOCTLs. Mark Roddy On Sat, Feb 17, 2018 at 11:25 PM, xxxxx@probo.com <xxxxx@lists.osr.com> wrote: > On Feb 17, 2018, at 5:19 PM, xxxxx@rolle.name <xxxxx@lists.osr.com> wrote: > > > > Two questions here, one about Dpc and the other about IRP. > > > > (1) Can a driver have two CustomDpc functions running at the same time? > I realize that since they run at DISPATCH_LEVEL, they will be serialized on > the same processor. But what about different processors? > > > > My guess is that they are not serialized, and so can run concurrently on > different processors. That would mean that the routines need to use some <...excess quoted lines suppressed...> --
  Message 4 of 4  
20 Feb 18 12:15
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6192
List Moderator
Are Dpcs and IRPs serialized?

<quote> I plan to have the Acquire function post the IRP with DEVICE_BUSY if another Acquire is in effect, rather than put the calling thread in a wait state. </quote> Do you mean COMPLETE the IRP with STATUS_DEVICE_BUSY? If so, then... yeah. Just do that. But as Mr. Roddy implied... you PROBABLY shouldn't be doing this with IRPs at all. You *probably* should be using WDF, in which case what you want to do would (probably) be easier. Peter OSR @OSRDrivers
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 17:45.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license