当前位置: 首页>>代码示例>>C++>>正文


C++ KeAcquireSpinLock函数代码示例

本文整理汇总了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;
}
开发者ID:MartinDrab,项目名称:IRPMon,代码行数:36,代码来源:hash_table.c

示例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);
}
开发者ID:eejackliu,项目名称:graphics-driver-samples,代码行数:39,代码来源:RosKmdAdapter.cpp

示例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);
}
开发者ID:RareHare,项目名称:reactos,代码行数:22,代码来源:fcb.c

示例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;
}
开发者ID:Endt4sk,项目名称:sebek,代码行数:22,代码来源:datapipe.c

示例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;
}
开发者ID:virendramishra,项目名称:VirtualBox4.1.18,代码行数:22,代码来源:VBoxMFInternal.cpp

示例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);
}
开发者ID:JanD1943,项目名称:ndas4windows,代码行数:39,代码来源:network.c

示例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);
}
开发者ID:210230,项目名称:com0com,代码行数:39,代码来源:startirp.c

示例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(&notifynode->entry);
			RtlCopyMemory(&notifynode->notification, notification, sizeof(PGNOTIFICATION));

			InsertTailList(&queue->notification_list, &notifynode->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);
	}
}
开发者ID:Tudi,项目名称:PG2-firewall,代码行数:38,代码来源:notifyqueue.c

示例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);
    }
}
开发者ID:OpenXT,项目名称:xc-windows,代码行数:38,代码来源:pdo.c

示例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;
}
开发者ID:cutepig123,项目名称:GeneralUtility,代码行数:38,代码来源:capvideo.c

示例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;

}
开发者ID:kcrazy,项目名称:winekit,代码行数:38,代码来源:anlgevent.cpp

示例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;
}
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:56,代码来源:clntirp.c

示例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;
}
开发者ID:Bobfrat,项目名称:coi-services,代码行数:38,代码来源:openclos.c

示例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);
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:23,代码来源:VBoxMPVhwa.cpp

示例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);
}
开发者ID:LucaBongiorni,项目名称:winfsp,代码行数:23,代码来源:file.c


注:本文中的KeAcquireSpinLock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。