本文整理汇总了C++中KeAcquireSpinLock函数的典型用法代码示例。如果您正苦于以下问题:C++ KeAcquireSpinLock函数的具体用法?C++ KeAcquireSpinLock怎么用?C++ KeAcquireSpinLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KeAcquireSpinLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HashTableLockShared
/** Locks a given table bucket for shared access.
*
* @param Table Table which bucket is about to be locked.
* @param Index A zero-based index of the bucket to lock.
* @param Irql Address of variable. If the table is not a dispatch IRQL
* one, this parameter is ignored. Otherwise, the variable is filled with
* the current IRQL value just before the locking in shared mode is performed.
*
* @remark
* If access to the table is not synchronized, the routine performs nothing.
*
* The @link(HASH_TABLE_IRQL_VALIDATE) is used to check whether the caller
* runs at a valid IRQL.
*/
static VOID HashTableLockShared(PHASH_TABLE Table, ULONG32 Index, PKIRQL Irql)
{
HASH_TABLE_IRQL_VALIDATE(Table);
ASSERT(Index < Table->Size);
switch (Table->Type) {
case httPassiveLevel:
KeEnterCriticalRegion();
ExAcquireResourceSharedLite(&Table->Locks[Index], TRUE);
break;
case httDispatchLevel:
KeAcquireSpinLock(&Table->DispatchLocks[Index], Irql);
break;
case httNoSynchronization:
break;
default:
DEBUG_ERROR("Invalid hash table type: %u", Table->Type);
break;
}
return;
}
示例2: KeAcquireSpinLock
void
RosKmAdapter::QueueDmaBuffer(
IN_CONST_PDXGKARG_SUBMITCOMMAND pSubmitCommand)
{
ROSDMABUFINFO * pDmaBufInfo = (ROSDMABUFINFO *)pSubmitCommand->pDmaBufferPrivateData;
KIRQL OldIrql;
ROSDMABUFSUBMISSION * pDmaBufSubmission;
KeAcquireSpinLock(&m_dmaBufQueueLock, &OldIrql);
//
// Combination indicating preparation error, thus the DMA buffer should be discarded
//
if ((pSubmitCommand->DmaBufferPhysicalAddress.QuadPart == 0) &&
(pSubmitCommand->DmaBufferSubmissionStartOffset == 0) &&
(pSubmitCommand->DmaBufferSubmissionEndOffset == 0))
{
m_ErrorHit.m_PreparationError = 1;
}
if (!pDmaBufInfo->m_DmaBufState.m_bSubmittedOnce)
{
pDmaBufInfo->m_DmaBufState.m_bSubmittedOnce = 1;
}
NT_ASSERT(!IsListEmpty(&m_dmaBufSubmissionFree));
pDmaBufSubmission = CONTAINING_RECORD(RemoveHeadList(&m_dmaBufSubmissionFree), ROSDMABUFSUBMISSION, m_QueueEntry);
pDmaBufSubmission->m_pDmaBufInfo = pDmaBufInfo;
pDmaBufSubmission->m_StartOffset = pSubmitCommand->DmaBufferSubmissionStartOffset;
pDmaBufSubmission->m_EndOffset = pSubmitCommand->DmaBufferSubmissionEndOffset;
pDmaBufSubmission->m_SubmissionFenceId = pSubmitCommand->SubmissionFenceId;
InsertTailList(&m_dmaBufQueue, &pDmaBufSubmission->m_QueueEntry);
KeReleaseSpinLock(&m_dmaBufQueueLock, OldIrql);
}
示例3: NtfsReleaseFCB
VOID
NtfsReleaseFCB(PNTFS_VCB Vcb,
PNTFS_FCB Fcb)
{
KIRQL oldIrql;
DPRINT("releasing FCB at %p: %S, refCount:%d\n",
Fcb,
Fcb->PathName,
Fcb->RefCount);
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
Fcb->RefCount--;
if (Fcb->RefCount <= 0 && !NtfsFCBIsDirectory(Fcb))
{
RemoveEntryList(&Fcb->FcbListEntry);
CcUninitializeCacheMap(Fcb->FileObject, NULL, NULL);
NtfsDestroyFCB(Fcb);
}
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
}
示例4: datapipe_get
ULONG datapipe_get(datapipe_t *dp, char *buf, ULONG size)
{
struct datapipe_entry *de;
ULONG result = 0;
KIRQL irql;
KeAcquireSpinLock(&dp->guard, &irql);
de = dp->first;
if (!de) goto done;
if (de->size > size) goto done;
dp->first = de->next;
memcpy(buf, de->data, de->size);
result = de->size;
free(de);
done:
KeReleaseSpinLock(&dp->guard, irql);
return result;
}
示例5: vboxNewProtDeviceAdded
static NTSTATUS vboxNewProtDeviceAdded(PVBOXMOUSE_DEVEXT pDevExt)
{
if (!vboxNewProtIsEnabled())
{
WARN(("New Protocol is disabled"));
return STATUS_UNSUCCESSFUL;
}
NTSTATUS Status = STATUS_SUCCESS;
KIRQL Irql;
KeAcquireSpinLock(&g_ctx.SyncLock, &Irql);
InsertHeadList(&g_ctx.DevExtList, &pDevExt->ListEntry);
if (!g_ctx.pCurrentDevExt)
{
ASMAtomicWritePtr(&g_ctx.pCurrentDevExt, pDevExt);
/* ensure the object is not deleted while it is being used by a poller thread */
ObReferenceObject(pDevExt->pdoSelf);
}
KeReleaseSpinLock(&g_ctx.SyncLock, Irql);
return Status;
}
示例6: NdasPortClearLpxLocalAddressList
VOID
NdasPortClearLpxLocalAddressList(
PNDASPORT_DRIVER_EXTENSION DriverExtension)
{
PLIST_ENTRY entry;
KIRQL oldIrql;
KeAcquireSpinLock(&DriverExtension->LpxLocalAddressListSpinLock, &oldIrql);
entry = DriverExtension->LpxLocalAddressList.Flink;
while (entry != &DriverExtension->LpxLocalAddressList)
{
PTDI_ADDRESS_LPX_LIST_ENTRY lpxAddressEntry;
lpxAddressEntry = CONTAINING_RECORD(
entry,
TDI_ADDRESS_LPX_LIST_ENTRY,
ListEntry);
//
// Forward the link first
//
entry = entry->Flink;
//
// And remove the actual entry
//
RemoveEntryList(&lpxAddressEntry->ListEntry);
//
// Now we can free the allocated list
//
ExFreePoolWithTag(
lpxAddressEntry,
NDASPORT_TAG_TDI);
}
KeReleaseSpinLock(&DriverExtension->LpxLocalAddressListSpinLock, oldIrql);
}
示例7: CancelRoutine
VOID CancelRoutine(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp)
{
LIST_ENTRY queueToComplete;
PC0C_IO_PORT pIoPort;
PC0C_IRP_STATE pState;
KIRQL oldIrql;
PC0C_IRP_QUEUE pQueue;
IoReleaseCancelSpinLock(pIrp->CancelIrql);
pIoPort = FDO_PORT_TO_IO_PORT(pDevObj);
pState = GetIrpState(pIrp);
HALT_UNLESS(pState);
pQueue = &pIoPort->irpQueues[pState->iQueue];
InitializeListHead(&queueToComplete);
KeAcquireSpinLock(pIoPort->pIoLock, &oldIrql);
if (pState->flags & C0C_IRP_FLAG_IN_QUEUE) {
RemoveEntryList(&pIrp->Tail.Overlay.ListEntry);
pState->flags &= ~C0C_IRP_FLAG_IN_QUEUE;
}
pIrp->IoStatus.Status = STATUS_CANCELLED;
InsertTailList(&queueToComplete, &pIrp->Tail.Overlay.ListEntry);
if (pState->flags & C0C_IRP_FLAG_IS_CURRENT) {
ShiftQueue(pQueue);
if (pState->iQueue == C0C_QUEUE_WRITE)
ReadWrite(pIoPort->pIoPortRemote, FALSE, pIoPort, FALSE, &queueToComplete);
}
KeReleaseSpinLock(pIoPort->pIoLock, oldIrql);
FdoPortCompleteQueue(&queueToComplete);
}
示例8: Notification_Send
void Notification_Send(NOTIFICATION_QUEUE *queue, const PGNOTIFICATION *notification) {
KIRQL irq;
KeAcquireSpinLock(&queue->lock, &irq);
if(IsListEmpty(&queue->irp_list)) {
if(queue->queued < 64) {
PGNOTIFYNODE *notifynode;
notifynode = ExAllocateFromNPagedLookasideList(&queue->lookaside);
InitializeListHead(¬ifynode->entry);
RtlCopyMemory(¬ifynode->notification, notification, sizeof(PGNOTIFICATION));
InsertTailList(&queue->notification_list, ¬ifynode->entry);
++queue->queued;
}
KeReleaseSpinLock(&queue->lock, irq);
}
else {
PGIRPNODE *irpnode = (PGIRPNODE*)RemoveHeadList(&queue->irp_list);
PGNOTIFICATION *irpnotification = irpnode->irp->AssociatedIrp.SystemBuffer;
PIRP irp;
RtlCopyMemory(irpnotification, notification, sizeof(PGNOTIFICATION));
irp = irpnode->irp;
ExFreeToNPagedLookasideList(&queue->lookaside, irpnode);
KeReleaseSpinLock(&queue->lock, irq);
irp->IoStatus.Status = STATUS_SUCCESS;
irp->IoStatus.Information = sizeof(PGNOTIFICATION);
IoCompleteRequest(irp, IO_NO_INCREMENT);
}
}
示例9: XenM2BPdoUnlink
VOID
XenM2BPdoUnlink(PXENM2B_PDO_EXTENSION pPdoExt,
BOOLEAN Locked)
{
PXENM2B_FDO_EXTENSION pFdoExt;
PXENM2B_HID_CONTEXT pHidCtx = pPdoExt->pHidCtx;
PLIST_ENTRY pEntry = &pPdoExt->ListEntry;
KIRQL Irql;
ASSERT(pPdoExt->pFdo != NULL);
pFdoExt = (PXENM2B_FDO_EXTENSION)pPdoExt->pFdo->DeviceExtension;
ASSERT(pFdoExt != NULL);
if (!Locked)
KeAcquireSpinLock(&pFdoExt->PdoListLock, &Irql);
// If we are unlinking the active Pdo due to a device removal we need to reset the active hid context.
//
if (pFdoExt->pActiveHidCtx == pHidCtx) {
pFdoExt->pActiveHidCtx = NULL;
XenM2BReleaseHidContext(pHidCtx);
}
RemoveEntryList(pEntry);
pPdoExt->pFdo = NULL;
ASSERT(pFdoExt->References != 0);
pFdoExt->References--;
if (!Locked)
KeReleaseSpinLock(&pFdoExt->PdoListLock, Irql);
// If the removed Pdo had the final reference to the Fdo, delete the Fdo now.
//
if (pFdoExt->References == 0) {
ASSERT(!Locked);
XenM2BDeleteDevice(pFdoExt);
}
}
示例10: RemoveFromListIfAvailable
BOOL
STREAMAPI
RemoveFromListIfAvailable (
IN OUT PHW_STREAM_REQUEST_BLOCK *pSrb,
IN KSPIN_LOCK *SpinLock,
IN OUT BOOL *BusyFlag,
IN LIST_ENTRY *ListHead
)
{
KIRQL Irql;
KeAcquireSpinLock (SpinLock, &Irql);
//
// If the queue is now empty, clear the busy flag, and return
//
if (IsListEmpty(ListHead)) {
*BusyFlag = FALSE;
KeReleaseSpinLock(SpinLock, Irql);
return FALSE;
}
//
// otherwise extract the SRB
//
else {
PUCHAR ptr;
PSRB_EXTENSION pSrbExt;
ptr = (PUCHAR)RemoveHeadList(ListHead);
*BusyFlag = TRUE;
KeReleaseSpinLock(SpinLock, Irql);
// Get the SRB out of the SRB extension and return it
pSrbExt = (PSRB_EXTENSION) (((PUCHAR) ptr) -
FIELDOFFSET(SRB_EXTENSION, ListEntry));
*pSrb = pSrbExt->pSrb;
}
return TRUE;
}
示例11: AnlgTunerScanRemoveEvent
VOID
AnlgTunerScanRemoveEvent(
PFILE_OBJECT FileObject,
struct _KSEVENT_ENTRY* EventEntry
)
{
KIRQL OldIrql;
CEncoderDevice* pEncDevice = NULL;
DbgPrint("AnlgTunerScanRemoveEvent enter!\n");
PKSFILTER Filter = KsGetFilterFromFileObject(FileObject);
ASSERT(Filter);
if (!Filter) return;
ASSERT(EventEntry);
PKSDEVICE pDevice = KsFilterGetDevice(Filter);
pEncDevice = reinterpret_cast<CEncoderDevice *>(pDevice->Context);
KeAcquireSpinLock(&pEncDevice->EventHandlerSpinLock, &OldIrql);
if(pEncDevice->ScanInitialization)
RemoveEntryList(&EventEntry->ListEntry);
if (pEncDevice->pScanEvent)
{
pEncDevice->pScanEvent = NULL;
pEncDevice->EventData = NULL;
pEncDevice->ScanInitialization = FALSE;
if (EventHandler)//if not already stopped due to the end of the range stop it
{
EventHandler->bStopScan = TRUE;
KeSetEvent(&(EventHandler->TuneEvent), 0,FALSE);
}
}
KeReleaseSpinLock(&pEncDevice->EventHandlerSpinLock, OldIrql);
return;
}
示例12: ClasspDequeueIdleRequest
/*++
ClasspDequeueIdleRequest
Routine Description:
This function will remove the next idle request from the list.
If there are no requests in the queue, then it will return NULL.
Arguments:
FdoExtension - Pointer to the functional device extension
Return Value:
Pointer to removed IRP
--*/
PIRP
ClasspDequeueIdleRequest(
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
)
{
PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
PLIST_ENTRY listEntry = NULL;
PIRP irp = NULL;
KIRQL oldIrql;
KeAcquireSpinLock(&fdoData->IdleListLock, &oldIrql);
if (fdoData->IdleIoCount > 0) {
listEntry = RemoveHeadList(&fdoData->IdleIrpList);
//
// Make sure we actaully removed a request from the list
//
NT_ASSERT(listEntry != &fdoData->IdleIrpList);
//
// Decrement the idle I/O count.
//
fdoData->IdleIoCount--;
//
// Stop the timer on last request
//
if (fdoData->IdleIoCount == 0) {
ClasspStopIdleTimer(fdoData);
}
irp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry);
NT_ASSERT(irp->Type == IO_TYPE_IRP);
InitializeListHead(&irp->Tail.Overlay.ListEntry);
}
KeReleaseSpinLock(&fdoData->IdleListLock, oldIrql);
return irp;
}
示例13: FdoPortClose
NTSTATUS FdoPortClose(IN PC0C_FDOPORT_EXTENSION pDevExt, IN PIRP pIrp)
{
NTSTATUS status;
LIST_ENTRY queueToComplete;
KIRQL oldIrql;
PC0C_IO_PORT pIoPort;
pIoPort = pDevExt->pIoPortLocal;
pIoPort->isOpen = FALSE;
if (pIoPort->pIoPortRemote->plugInMode)
IoInvalidateDeviceRelations(pIoPort->pIoPortRemote->pPhDevObj, BusRelations);
InitializeListHead(&queueToComplete);
KeAcquireSpinLock(pIoPort->pIoLock, &oldIrql);
pIoPort->escapeChar = 0;
pIoPort->writeHoldingRemote = 0;
pIoPort->sendXonXoff = 0;
SetModemControl(pIoPort, C0C_MCR_OUT2, C0C_MCR_MASK | C0C_MCR_OPEN, &queueToComplete);
FreeBuffer(&pIoPort->readBuf);
SetBreakHolding(pIoPort, FALSE, &queueToComplete);
KeReleaseSpinLock(pIoPort->pIoLock, oldIrql);
FdoPortCompleteQueue(&queueToComplete);
status = FdoPortStartIrp(pIoPort, pIrp, C0C_QUEUE_CLOSE, StartIrpClose);
if (status != STATUS_PENDING) {
pIrp->IoStatus.Status = status;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
}
return status;
}
示例14: vboxVhwaHlpOverlayDstRectUnion
void vboxVhwaHlpOverlayDstRectUnion(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, RECT *pRect)
{
if (vboxVhwaHlpOverlayListIsEmpty(pDevExt, VidPnSourceId))
{
memset(pRect, 0, sizeof (*pRect));
return;
}
PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
KIRQL OldIrql;
KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql);
if (pSource->cOverlays)
{
PVBOXWDDM_OVERLAY pOverlay = VBOXWDDM_OVERLAY_FROM_ENTRY(pSource->OverlayList.Flink);
*pRect = pOverlay->DstRect;
while (pOverlay->ListEntry.Flink != &pSource->OverlayList)
{
pOverlay = VBOXWDDM_OVERLAY_FROM_ENTRY(pOverlay->ListEntry.Flink);
vboxWddmRectUnite(pRect, &pOverlay->DstRect);
}
}
KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql);
}
示例15: FspFileNodeSetDirInfo
VOID FspFileNodeSetDirInfo(FSP_FILE_NODE *FileNode, PCVOID Buffer, ULONG Size)
{
// !PAGED_CODE();
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension =
FspFsvolDeviceExtension(FileNode->FsvolDeviceObject);
FSP_FILE_NODE_NONPAGED *NonPaged = FileNode->NonPaged;
KIRQL Irql;
UINT64 DirInfo;
/* no need to acquire the DirInfoSpinLock as the FileNode is acquired */
DirInfo = NonPaged->DirInfo;
FspMetaCacheInvalidateItem(FsvolDeviceExtension->DirInfoCache, DirInfo);
DirInfo = 0 != Buffer ?
FspMetaCacheAddItem(FsvolDeviceExtension->DirInfoCache, Buffer, Size) : 0;
FileNode->DirInfoChangeNumber++;
/* acquire the DirInfoSpinLock to protect against concurrent FspFileNodeInvalidateDirInfo */
KeAcquireSpinLock(&NonPaged->DirInfoSpinLock, &Irql);
NonPaged->DirInfo = DirInfo;
KeReleaseSpinLock(&NonPaged->DirInfoSpinLock, Irql);
}