summaryrefslogtreecommitdiff
path: root/general/echo/kmdf/driver/DriverSync/queue.c
diff options
context:
space:
mode:
authorWei Mao <[email protected]>2017-06-21 09:41:28 -0700
committerWei Mao <[email protected]>2017-06-21 09:46:42 -0700
commit6a7b5d032d331efe11d1c8f33f399296e529d9b7 (patch)
treeef98ffe35d091fa7711ee7a843ee82d16c8180bd /general/echo/kmdf/driver/DriverSync/queue.c
parent72d6e020298b18db58119f6b1ab66f1b917f0deb (diff)
issue #127: Remove timerConfig.AutomaticSerialization = FALSE from KMDF echo sample
Diffstat (limited to 'general/echo/kmdf/driver/DriverSync/queue.c')
-rw-r--r--general/echo/kmdf/driver/DriverSync/queue.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/general/echo/kmdf/driver/DriverSync/queue.c b/general/echo/kmdf/driver/DriverSync/queue.c
index 78c199d2..7835b73b 100644
--- a/general/echo/kmdf/driver/DriverSync/queue.c
+++ b/general/echo/kmdf/driver/DriverSync/queue.c
@@ -158,6 +158,18 @@ Return Value:
// Fill in a callback for destroy, and our QUEUE_CONTEXT size
//
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, QUEUE_CONTEXT);
+
+ //
+ // By not setting the synchronization scope and using the default, there is
+ // no locking between any of the callbacks in this driver.
+ //
+ // We will create a sequential queue so all of the EvtIoXxx callbacks are
+ // serialized against each other (at least until the request is completed),
+ // but the cancel routine and the timer DPC are not synchronized against the
+ // queue's EvtIoXxx callbacks.
+ //
+ // attributes.SynchronizationScope = ...
+
attributes.EvtDestroyCallback = EchoEvtIoQueueContextDestroy;
status = WdfIoQueueCreate(
@@ -192,7 +204,7 @@ Return Value:
KdPrint(("WdfSpinLockCreate failed 0x%x\n",status));
return status;
}
-
+
//
// Create the Queue timer
//
@@ -234,16 +246,15 @@ Return Value:
PAGED_CODE();
//
- // Create a WDFTIMER object
+ // Create a periodic timer.
+ //
+ // By not setting the synchronization scope and using the default at WdfIoQueueCreate,
+ // we are explicitly *not* serializing against the queue's lock. Instead, we will do
+ // that on our own.
//
WDF_TIMER_CONFIG_INIT_PERIODIC(&timerConfig, EchoEvtTimerFunc, Period);
WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes);
-
- //
- // We are explicitly *not* serializing against the queue's lock, we will do
- // that on our own.
- //
timerAttributes.ParentObject = Queue;
Status = WdfTimerCreate(
@@ -456,9 +467,9 @@ EchoSetCurrentRequest(
queueContext->CurrentStatus = STATUS_SUCCESS;
//
- // Set the cancel routine under the lock, otherwise if we set it outside
- // of the lock, the timer could run and attempt to mark the request
- // uncancelable before we can mark it cancelable on this thread. Use
+ // Set the cancel routine under the lock, otherwise if we set it outside
+ // of the lock, the timer could run and attempt to mark the request
+ // uncancelable before we can mark it cancelable on this thread. Use
// WdfRequestMarkCancelableEx here to prevent to deadlock with ourselves
// (cancel routine tries to acquire the queue object lock).
//
@@ -746,7 +757,7 @@ Return Value:
//
}
}
-
+
WdfSpinLockRelease(queueContext->SpinLock);
//