WDFTIMER, WDFWORKITEM, and Device Scope Syncronization @ Passive Level

As I understand it (and my understanding is very tenuous) I can have the
framework provide device syncronization scope at passive level and still
create WDFTIMER objects that are ‘owned’ (parented?) by the WDFDEVICE as
long as I explicitly release the WDFTIMER from the default syncronization
scope by specifying WDF_OBJECT_ATTRIBUTES::AutomaticSyncronization=WdfFalse
when I create the WDFTIMER.

My question is this:

If I simply schedule a WDFWORKITEM from the timer callback assuming the
WDFWORKITEM was created with AutomaticSyncronization=WdfTrue and is ‘owned’
(parented) by the WDFDEVICE, will the workitem be syncronized to device
scope at passive level?

I am fairly certain that the object lifetimes are all fine and that
‘touching’ the fields in the various objects context areas needed to ensure
the work-item is not queued again while still running and that the timer is
activated only when the workitem completes, etc. is safe given that this can
all be neatly syncronized with InterlockedIncrement/Decrement or an explicit
WDFSPINLOCK.

Is there something I am missing about the implications of setting
AutomaticSyncronization=False in a WDFTIMER that would make this approach
senseless?

TIA,
-dave

David R. Cattley
Consulting Engineer
Systems Software Development

This should work the way you expect. In this particular case, the
objects themselves would not you to create them if you had an
incompatible sync scope/execution level set for the device. Since you
are specifying passive level sync, you can have a work item use the lock
and must specifically have the timer NOT opt into locking (which is what
you did by setting AutomaticSynchronization to FALSE (it is not a
WDF_TRI_STATE, so TRUE and FALSE apply here although we realized there
could be confusion between a WDF_TRI_STATE and a BOOLEAN so WdfTrue =
TRUE, WdfFalse = FALSE so that you don’t mistakenly set the wrong value)

d

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David R. Cattley
Sent: Wednesday, May 02, 2007 8:44 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WDFTIMER, WDFWORKITEM, and Device Scope Syncronization
@ Passive Level

As I understand it (and my understanding is very tenuous) I can have the
framework provide device syncronization scope at passive level and still
create WDFTIMER objects that are ‘owned’ (parented?) by the WDFDEVICE as
long as I explicitly release the WDFTIMER from the default
syncronization scope by specifying
WDF_OBJECT_ATTRIBUTES::AutomaticSyncronization=WdfFalse when I create
the WDFTIMER.

My question is this:

If I simply schedule a WDFWORKITEM from the timer callback assuming the
WDFWORKITEM was created with AutomaticSyncronization=WdfTrue and is
‘owned’ (parented) by the WDFDEVICE, will the workitem be syncronized to
device scope at passive level?

I am fairly certain that the object lifetimes are all fine and that
‘touching’ the fields in the various objects context areas needed to
ensure the work-item is not queued again while still running and that
the timer is activated only when the workitem completes, etc. is safe
given that this can all be neatly syncronized with
InterlockedIncrement/Decrement or an explicit WDFSPINLOCK.

Is there something I am missing about the implications of setting
AutomaticSyncronization=False in a WDFTIMER that would make this
approach senseless?

TIA,

-dave

David R. Cattley

Consulting Engineer

Systems Software Development


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer