How device scope affect Queues dispatching mode

I read that “device scope results in serialized calls to the I/O event callbacks for an individual device object”.
If parallel dispatching mode is set for the queue, Would this ‘device scope’ causes serialized calls (sequential) calls to the I/O callbacks which driver registered for read, write and control?

Yes.

Sync Scope Device locates a lock at the device level. Before calling any of your driver’s EvtIo Event Processing Callbacks, the Framework acquires this lock exclusive. That means that while one of your EvtIo callbacks (EvtIoRead, for example) is running no other such callback EvtIo callback can be made active. When it’s about to call, the Framework will just wait to acquire the lock.

Note the lock is only held while the callback is in progress. As soon as the EvtIo routine holding the lock returns, the lock is release, and the next (one) such callback can run.

And, let me add, that Sync Scope Device is rarely the right answer to anything. In most drivers where I’ve seen it used, it’s the result of the dev not really understanding the synchronization needs of their driver. I’m not saying I’ve never used it (I have… in a very complex driver I wrote last year). I’m just saying it’s rarely the best option (and, truth be told, if I had more time to work on that driver that I wrote where I used it, I wouldn’t have used it there either).

Peter

1 Like

Yes. One of the things I learned very early in my experience with KMDF is that the framework makes it very easy to oversynchronize yourself. Before I figured out their scheme, I had some very nasty hangs .

2 Likes

Thanks all. Suppose, I have three different queues with sequential dispatching (for read, write and control). Does this device scope means, only one IO event callback function shall be in progress at anytime?

Does this device scope means, only one IO event callback function shall be in progress at anytime

Yes. That’s what it means.

Apparently I did not do a good job of explaining that in my initial reply.

Peter

Thanks!