本文整理汇总了C++中RTThreadNativeSelf函数的典型用法代码示例。如果您正苦于以下问题:C++ RTThreadNativeSelf函数的具体用法?C++ RTThreadNativeSelf怎么用?C++ RTThreadNativeSelf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTThreadNativeSelf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rtTimerNtSimpleCallback
/**
* Timer callback function for the non-omni timers.
*
* @returns HRTIMER_NORESTART or HRTIMER_RESTART depending on whether it's a one-shot or interval timer.
* @param pDpc Pointer to the DPC.
* @param pvUser Pointer to our internal timer structure.
* @param SystemArgument1 Some system argument.
* @param SystemArgument2 Some system argument.
*/
static void _stdcall rtTimerNtSimpleCallback(IN PKDPC pDpc, IN PVOID pvUser, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
{
PRTTIMER pTimer = (PRTTIMER)pvUser;
AssertPtr(pTimer);
#ifdef RT_STRICT
if (KeGetCurrentIrql() < DISPATCH_LEVEL)
RTAssertMsg2Weak("rtTimerNtSimpleCallback: Irql=%d expected >=%d\n", KeGetCurrentIrql(), DISPATCH_LEVEL);
#endif
/*
* Check that we haven't been suspended before doing the callout.
*/
if ( !ASMAtomicUoReadBool(&pTimer->fSuspended)
&& pTimer->u32Magic == RTTIMER_MAGIC)
{
ASMAtomicWriteHandle(&pTimer->aSubTimers[0].hActiveThread, RTThreadNativeSelf());
if (!pTimer->u64NanoInterval)
ASMAtomicWriteBool(&pTimer->fSuspended, true);
uint64_t iTick = ++pTimer->aSubTimers[0].iTick;
if (pTimer->u64NanoInterval)
rtTimerNtRearmInternval(pTimer, iTick, &pTimer->aSubTimers[0].NtDpc);
pTimer->pfnTimer(pTimer, pTimer->pvUser, iTick);
ASMAtomicWriteHandle(&pTimer->aSubTimers[0].hActiveThread, NIL_RTNATIVETHREAD);
}
NOREF(pDpc); NOREF(SystemArgument1); NOREF(SystemArgument2);
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:38,代码来源:timer-r0drv-nt.cpp
示例2: rtTimerNtOmniSlaveCallback
/**
* The slave DPC callback for an omni timer.
*
* @param pDpc The DPC object.
* @param pvUser Pointer to the sub-timer.
* @param SystemArgument1 Some system stuff.
* @param SystemArgument2 Some system stuff.
*/
static void _stdcall rtTimerNtOmniSlaveCallback(IN PKDPC pDpc, IN PVOID pvUser, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
{
PRTTIMERNTSUBTIMER pSubTimer = (PRTTIMERNTSUBTIMER)pvUser;
PRTTIMER pTimer = pSubTimer->pParent;
AssertPtr(pTimer);
#ifdef RT_STRICT
if (KeGetCurrentIrql() < DISPATCH_LEVEL)
RTAssertMsg2Weak("rtTimerNtOmniSlaveCallback: Irql=%d expected >=%d\n", KeGetCurrentIrql(), DISPATCH_LEVEL);
int iCpuSelf = RTMpCpuIdToSetIndex(RTMpCpuId());
if (pSubTimer - &pTimer->aSubTimers[0] != iCpuSelf)
RTAssertMsg2Weak("rtTimerNtOmniSlaveCallback: iCpuSelf=%d pSubTimer=%p / %d\n", iCpuSelf, pSubTimer, pSubTimer - &pTimer->aSubTimers[0]);
#endif
/*
* Check that we haven't been suspended before doing the callout.
*/
if ( !ASMAtomicUoReadBool(&pTimer->fSuspended)
&& pTimer->u32Magic == RTTIMER_MAGIC)
{
ASMAtomicWriteHandle(&pSubTimer->hActiveThread, RTThreadNativeSelf());
if (!pTimer->u64NanoInterval)
if (ASMAtomicDecS32(&pTimer->cOmniSuspendCountDown) <= 0)
ASMAtomicWriteBool(&pTimer->fSuspended, true);
pTimer->pfnTimer(pTimer, pTimer->pvUser, ++pSubTimer->iTick);
ASMAtomicWriteHandle(&pSubTimer->hActiveThread, NIL_RTNATIVETHREAD);
}
NOREF(pDpc); NOREF(SystemArgument1); NOREF(SystemArgument2);
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:41,代码来源:timer-r0drv-nt.cpp
示例3: AssertMsg
/**
* Toggle fullscreen mode
*
* @remarks Must be called from the SDL thread!
*/
void SDLFramebuffer::setFullscreen(bool fFullscreen)
{
AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
LogFlow(("SDLFramebuffer::SetFullscreen: fullscreen: %d\n", fFullscreen));
mfFullscreen = fFullscreen;
resize();
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:12,代码来源:SDLFramebuffer.cpp
示例4: RTDECL
RTDECL(int) RTThreadCtxHookEnable(RTTHREADCTXHOOK hCtxHook)
{
/*
* Validate input.
*/
PRTTHREADCTXHOOKINT pThis = hCtxHook;
AssertPtr(pThis);
AssertMsgReturn(pThis->u32Magic == RTTHREADCTXHOOKINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis),
VERR_INVALID_HANDLE);
Assert(pThis->hOwner == RTThreadNativeSelf());
Assert(!pThis->fEnabled);
if (!pThis->fEnabled)
{
IPRT_LINUX_SAVE_EFL_AC();
Assert(pThis->PreemptOps.sched_out == rtThreadCtxHooksLnxSchedOut);
Assert(pThis->PreemptOps.sched_in == rtThreadCtxHooksLnxSchedIn);
/*
* Register the callback.
*/
preempt_disable();
pThis->fEnabled = true;
preempt_notifier_register(&pThis->LnxPreemptNotifier);
preempt_enable();
IPRT_LINUX_RESTORE_EFL_AC();
}
return VINF_SUCCESS;
}
开发者ID:miguelinux,项目名称:vbox,代码行数:30,代码来源:threadctxhooks-r0drv-linux.c
示例5: RTDECL
RTDECL(int) RTSemSpinMutexRelease(RTSEMSPINMUTEX hSpinMtx)
{
RTSEMSPINMUTEXINTERNAL *pThis = hSpinMtx;
RTNATIVETHREAD hSelf = RTThreadNativeSelf();
uint32_t cLockers;
RTSEMSPINMUTEXSTATE State;
bool fRc;
Assert(hSelf != NIL_RTNATIVETHREAD);
RTSEMSPINMUTEX_VALIDATE_RETURN(pThis);
/*
* Get the saved state and try release the semaphore.
*/
State = pThis->SavedState;
ASMCompilerBarrier();
ASMAtomicCmpXchgHandle(&pThis->hOwner, NIL_RTNATIVETHREAD, hSelf, fRc);
AssertMsgReturn(fRc,
("hOwner=%p hSelf=%p cLockers=%d\n", pThis->hOwner, hSelf, pThis->cLockers),
VERR_NOT_OWNER);
cLockers = ASMAtomicDecS32(&pThis->cLockers);
rtSemSpinMutexLeave(&State);
if (cLockers > 0)
{
int rc = RTSemEventSignal(pThis->hEventSem);
AssertReleaseMsg(RT_SUCCESS(rc), ("RTSemEventSignal -> %Rrc\n", rc));
}
return VINF_SUCCESS;
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:30,代码来源:semspinmutex-r0drv-generic.c
示例6: rtThreadAdopt
/**
* Adopts the calling thread.
* No locks are taken or released by this function.
*/
static int rtThreadAdopt(RTTHREADTYPE enmType, unsigned fFlags, uint32_t fIntFlags, const char *pszName)
{
int rc;
PRTTHREADINT pThread;
Assert(!(fFlags & RTTHREADFLAGS_WAITABLE));
fFlags &= ~RTTHREADFLAGS_WAITABLE;
/*
* Allocate and insert the thread.
* (It is vital that rtThreadNativeAdopt updates the TLS before
* we try inserting the thread because of locking.)
*/
rc = VERR_NO_MEMORY;
pThread = rtThreadAlloc(enmType, fFlags, RTTHREADINT_FLAGS_ALIEN | fIntFlags, pszName);
if (pThread)
{
RTNATIVETHREAD NativeThread = RTThreadNativeSelf();
rc = rtThreadNativeAdopt(pThread);
if (RT_SUCCESS(rc))
{
rtThreadInsert(pThread, NativeThread);
rtThreadSetState(pThread, RTTHREADSTATE_RUNNING);
rtThreadRelease(pThread);
}
}
return rc;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:31,代码来源:thread.cpp
示例7: RTDECL
RTDECL(int) RTThreadCtxHooksRegister(RTTHREADCTX hThreadCtx, PFNRTTHREADCTXHOOK pfnThreadCtxHook, void *pvUser)
{
/*
* Validate input.
*/
PRTTHREADCTXINT pThis = hThreadCtx;
if (pThis == NIL_RTTHREADCTX)
return VERR_INVALID_HANDLE;
AssertPtr(pThis);
AssertMsgReturn(pThis->u32Magic == RTTHREADCTXINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis),
VERR_INVALID_HANDLE);
Assert(pThis->hOwner == RTThreadNativeSelf());
Assert(!pThis->hPreemptOps.sched_out);
Assert(!pThis->hPreemptOps.sched_in);
/*
* Register the callback.
*/
pThis->hPreemptOps.sched_out = rtThreadCtxHooksLnxSchedOut;
pThis->hPreemptOps.sched_in = rtThreadCtxHooksLnxSchedIn;
pThis->pvUser = pvUser;
pThis->pfnThreadCtxHook = pfnThreadCtxHook;
pThis->fRegistered = true;
preempt_notifier_register(&pThis->hPreemptNotifier);
return VINF_SUCCESS;
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:27,代码来源:threadctxhooks-r0drv-linux.c
示例8: QTextEdit
VBoxDbgConsoleOutput::VBoxDbgConsoleOutput(QWidget *pParent/* = NULL*/, const char *pszName/* = NULL*/)
: QTextEdit(pParent), m_uCurLine(0), m_uCurPos(0), m_hGUIThread(RTThreadNativeSelf())
{
setReadOnly(true);
setUndoRedoEnabled(false);
setOverwriteMode(false);
setPlainText("");
setTextInteractionFlags(Qt::TextBrowserInteraction);
setAutoFormatting(QTextEdit::AutoAll);
setTabChangesFocus(true);
setAcceptRichText(false);
/*
* Font.
* Create actions for font menu items.
*/
m_pCourierFontAction = new QAction(tr("Courier"), this);
m_pCourierFontAction->setCheckable(true);
m_pCourierFontAction->setShortcut(Qt::ControlModifier + Qt::Key_D);
connect(m_pCourierFontAction, SIGNAL(triggered()), this, SLOT(setFontCourier()));
m_pMonospaceFontAction = new QAction(tr("Monospace"), this);
m_pMonospaceFontAction->setCheckable(true);
m_pMonospaceFontAction->setShortcut(Qt::ControlModifier + Qt::Key_M);
connect(m_pMonospaceFontAction, SIGNAL(triggered()), this, SLOT(setFontMonospace()));
/* Create action group for grouping of exclusive font menu items. */
QActionGroup *pActionFontGroup = new QActionGroup(this);
pActionFontGroup->addAction(m_pCourierFontAction);
pActionFontGroup->addAction(m_pMonospaceFontAction);
pActionFontGroup->setExclusive(true);
/*
* Color scheme.
* Create actions for color-scheme menu items.
*/
m_pGreenOnBlackAction = new QAction(tr("Green On Black"), this);
m_pGreenOnBlackAction->setCheckable(true);
m_pGreenOnBlackAction->setShortcut(Qt::ControlModifier + Qt::Key_1);
connect(m_pGreenOnBlackAction, SIGNAL(triggered()), this, SLOT(setColorGreenOnBlack()));
m_pBlackOnWhiteAction = new QAction(tr("Black On White"), this);
m_pBlackOnWhiteAction->setCheckable(true);
m_pBlackOnWhiteAction->setShortcut(Qt::ControlModifier + Qt::Key_2);
connect(m_pBlackOnWhiteAction, SIGNAL(triggered()), this, SLOT(setColorBlackOnWhite()));
/* Create action group for grouping of exclusive color-scheme menu items. */
QActionGroup *pActionColorGroup = new QActionGroup(this);
pActionColorGroup->addAction(m_pGreenOnBlackAction);
pActionColorGroup->addAction(m_pBlackOnWhiteAction);
pActionColorGroup->setExclusive(true);
/*
* Set the defaults (which syncs with the menu item checked state).
*/
setFontCourier();
setColorGreenOnBlack();
NOREF(pszName);
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:60,代码来源:VBoxDbgConsole.cpp
示例9: DECLINLINE
/**
* Internal worker.
*/
DECLINLINE(int) rtSemMutexSolRequest(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, bool fInterruptible)
{
PRTSEMMUTEXINTERNAL pThis = hMutexSem;
int rc = VERR_GENERAL_FAILURE;
/*
* Validate.
*/
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), VERR_INVALID_HANDLE);
Assert(pThis->cRefs >= 1);
/*
* Lock it and check if it's a recursion.
*/
mutex_enter(&pThis->Mtx);
if (pThis->hOwnerThread == RTThreadNativeSelf())
{
pThis->cRecursions++;
Assert(pThis->cRecursions > 1);
Assert(pThis->cRecursions < 256);
rc = VINF_SUCCESS;
}
/*
* Not a recursion, claim the unowned mutex if we're there are no waiters.
*/
else if ( pThis->hOwnerThread == NIL_RTNATIVETHREAD
&& pThis->cWaiters == 0)
{
pThis->cRecursions = 1;
pThis->hOwnerThread = RTThreadNativeSelf();
rc = VINF_SUCCESS;
}
/*
* A polling call?
*/
else if (cMillies == 0)
rc = VERR_TIMEOUT;
/*
* No, we really need to get to sleep.
*/
else
rc = rtSemMutexSolRequestSleep(pThis, cMillies, fInterruptible);
mutex_exit(&pThis->Mtx);
return rc;
}
开发者ID:bayasist,项目名称:vbox,代码行数:50,代码来源:semmutex-r0drv-solaris.c
示例10: Assert
void
VBoxDbgConsoleInput::setLineEdit(QLineEdit *pEdit)
{
Assert(m_hGUIThread == RTThreadNativeSelf());
QComboBox::setLineEdit(pEdit);
if (lineEdit() == pEdit && pEdit)
connect(pEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:8,代码来源:VBoxDbgConsole.cpp
示例11: rtThreadNativeMain
/**
* Native thread main function.
*
* @param pvThreadInt The thread structure.
*/
static void rtThreadNativeMain(void *pvThreadInt)
{
PRTTHREADINT pThreadInt = (PRTTHREADINT)pvThreadInt;
AssertCompile(sizeof(kt_did_t) == sizeof(pThreadInt->tid));
uint64_t *pu64ThrId = SOL_THREAD_ID_PTR;
pThreadInt->tid = *pu64ThrId;
rtThreadMain(pThreadInt, RTThreadNativeSelf(), &pThreadInt->szName[0]);
thread_exit();
}
开发者ID:zBMNForks,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:15,代码来源:thread2-r0drv-solaris.c
示例12: rtCritSectRwEnterShared
static int rtCritSectRwEnterShared(PRTCRITSECTRW pThis, PCRTLOCKVALSRCPOS pSrcPos, bool fTryOnly)
{
/*
* Validate input.
*/
AssertPtr(pThis);
AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
#ifdef IN_RING0
Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
#else
Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
#endif
#ifdef RTCRITSECTRW_STRICT
RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
if (!fTryOnly)
{
int rc9;
RTNATIVETHREAD hNativeWriter;
ASMAtomicUoReadHandle(&pThis->hNativeWriter, &hNativeWriter);
if (hNativeWriter != NIL_RTTHREAD && hNativeWriter == RTThreadNativeSelf())
rc9 = RTLockValidatorRecExclCheckOrder(pThis->pValidatorWrite, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
else
rc9 = RTLockValidatorRecSharedCheckOrder(pThis->pValidatorRead, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
if (RT_FAILURE(rc9))
return rc9;
}
#endif
/*
* Get cracking...
*/
uint64_t u64State = ASMAtomicReadU64(&pThis->u64State);
uint64_t u64OldState = u64State;
for (;;)
{
if ((u64State & RTCSRW_DIR_MASK) == (RTCSRW_DIR_READ << RTCSRW_DIR_SHIFT))
{
/* It flows in the right direction, try follow it before it changes. */
uint64_t c = (u64State & RTCSRW_CNT_RD_MASK) >> RTCSRW_CNT_RD_SHIFT;
c++;
Assert(c < RTCSRW_CNT_MASK / 2);
u64State &= ~RTCSRW_CNT_RD_MASK;
u64State |= c << RTCSRW_CNT_RD_SHIFT;
if (ASMAtomicCmpXchgU64(&pThis->u64State, u64State, u64OldState))
{
#ifdef RTCRITSECTRW_STRICT
RTLockValidatorRecSharedAddOwner(pThis->pValidatorRead, hThreadSelf, pSrcPos);
#endif
break;
}
}
else if ((u64State & (RTCSRW_CNT_RD_MASK | RTCSRW_CNT_WR_MASK)) == 0)
开发者ID:miguelinux,项目名称:vbox,代码行数:54,代码来源:critsectrw-generic.cpp
示例13: VMMDECL
/**
* Returns the VMCPU of the calling EMT.
*
* @returns The VMCPU pointer. NULL if not an EMT.
*
* @param pVM Pointer to the VM.
* @internal
*/
VMMDECL(PVMCPU) VMMGetCpu(PVM pVM)
{
#ifdef IN_RING3
VMCPUID idCpu = VMR3GetVMCPUId(pVM);
if (idCpu == NIL_VMCPUID)
return NULL;
Assert(idCpu < pVM->cCpus);
return &pVM->aCpus[idCpu];
#elif defined(IN_RING0)
if (pVM->cCpus == 1)
return &pVM->aCpus[0];
/*
* Search first by host cpu id (most common case)
* and then by native thread id (page fusion case).
*/
if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
{
/** @todo r=ramshankar: This doesn't buy us anything in terms of performance
* leaving it here for hysterical raisins and as a reference if we
* implemented a hashing approach in the future. */
RTCPUID idHostCpu = RTMpCpuId();
/** @todo optimize for large number of VCPUs when that becomes more common. */
for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
{
PVMCPU pVCpu = &pVM->aCpus[idCpu];
if (pVCpu->idHostCpu == idHostCpu)
return pVCpu;
}
}
/* RTThreadGetNativeSelf had better be cheap. */
RTNATIVETHREAD hThread = RTThreadNativeSelf();
/** @todo optimize for large number of VCPUs when that becomes more common.
* Use a map like GIP does that's indexed by the host CPU index. */
for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
{
PVMCPU pVCpu = &pVM->aCpus[idCpu];
if (pVCpu->hNativeThreadR0 == hThread)
return pVCpu;
}
return NULL;
#else /* RC: Always EMT(0) */
return &pVM->aCpus[0];
#endif /* IN_RING0 */
}
开发者ID:zBMNForks,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:60,代码来源:VMMAll.cpp
示例14: m_pDbgGui
VBoxDbgBase::VBoxDbgBase(VBoxDbgGui *a_pDbgGui)
: m_pDbgGui(a_pDbgGui), m_pVM(NULL), m_hGUIThread(RTThreadNativeSelf())
{
/*
* Register
*/
PVM pVM = a_pDbgGui->getVMHandle();
if (pVM)
{
m_pVM = pVM;
int rc = VMR3AtStateRegister(pVM, atStateChange, this);
AssertRC(rc);
}
}
开发者ID:VirtualMonitor,项目名称:VirtualMonitor,代码行数:14,代码来源:VBoxDbgBase.cpp
示例15: RTDECL
RTDECL(int) RTSemMutexRelease(RTSEMMUTEX hMutexSem)
{
/*
* Validate.
*/
RTSEMMUTEXINTERNAL *pThis = hMutexSem;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, VERR_INVALID_HANDLE);
/*
* Check ownership and recursions.
*/
RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
RTNATIVETHREAD hNativeOwner;
ASMAtomicReadHandle(&pThis->hNativeOwner, &hNativeOwner);
if (RT_UNLIKELY(hNativeOwner != hNativeSelf))
{
AssertMsgFailed(("Not owner of mutex %p!! hNativeSelf=%RTntrd Owner=%RTntrd cRecursions=%d\n",
pThis, hNativeSelf, hNativeOwner, pThis->cRecursions));
return VERR_NOT_OWNER;
}
if (pThis->cRecursions > 1)
{
#ifdef RTSEMMUTEX_STRICT
int rc9 = RTLockValidatorRecExclUnwind(&pThis->ValidatorRec);
if (RT_FAILURE(rc9))
return rc9;
#endif
ASMAtomicDecU32(&pThis->cRecursions);
return VINF_SUCCESS;
}
/*
* Unlock mutex semaphore.
*/
#ifdef RTSEMMUTEX_STRICT
int rc9 = RTLockValidatorRecExclReleaseOwner(&pThis->ValidatorRec, false);
if (RT_FAILURE(rc9))
return rc9;
#endif
ASMAtomicWriteU32(&pThis->cRecursions, 0);
ASMAtomicWriteHandle(&pThis->hNativeOwner, NIL_RTNATIVETHREAD);
if (ReleaseMutex(pThis->hMtx))
return VINF_SUCCESS;
int rc = RTErrConvertFromWin32(GetLastError());
AssertMsgFailed(("%p/%p, rc=%Rrc lasterr=%d\n", pThis, pThis->hMtx, rc, GetLastError()));
return rc;
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:50,代码来源:semmutex-win.cpp
示例16: DECL_FORCE_INLINE
/**
* Gets the ring-3 native thread handle of the calling thread.
*
* @returns native thread handle (ring-3).
* @param pCritSect The critical section. This is used in R0 and RC.
*/
DECL_FORCE_INLINE(RTNATIVETHREAD) pdmCritSectGetNativeSelf(PCPDMCRITSECT pCritSect)
{
#ifdef IN_RING3
NOREF(pCritSect);
RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
#else
AssertMsgReturn(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC, ("%RX32\n", pCritSect->s.Core.u32Magic),
NIL_RTNATIVETHREAD);
PVM pVM = pCritSect->s.CTX_SUFF(pVM); AssertPtr(pVM);
PVMCPU pVCpu = VMMGetCpu(pVM); AssertPtr(pVCpu);
RTNATIVETHREAD hNativeSelf = pVCpu->hNativeThread; Assert(hNativeSelf != NIL_RTNATIVETHREAD);
#endif
return hNativeSelf;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:20,代码来源:PDMAllCritSect.cpp
示例17: DECLINLINE
/**
* Internal worker for RTSemMutexRequest and RTSemMutexRequestNoResume
*
* @returns IPRT status code.
* @param hMutexSem The mutex handle.
* @param cMillies The timeout.
* @param fInterruptible Whether it's interruptible
* (RTSemMutexRequestNoResume) or not
* (RTSemMutexRequest).
*/
DECLINLINE(int) rtR0SemMutexDarwinRequest(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, wait_interrupt_t fInterruptible)
{
/*
* Validate input.
*/
PRTSEMMUTEXINTERNAL pThis = (PRTSEMMUTEXINTERNAL)hMutexSem;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, VERR_INVALID_HANDLE);
RT_ASSERT_PREEMPTIBLE();
IPRT_DARWIN_SAVE_EFL_AC();
/*
* Grab the lock and check out the state.
*/
RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
int rc = VINF_SUCCESS;
lck_spin_lock(pThis->pSpinlock);
/* Recursive call? */
if (pThis->hNativeOwner == hNativeSelf)
{
Assert(pThis->cRecursions > 0);
Assert(pThis->cRecursions < 256);
pThis->cRecursions++;
}
/* Is it free and nobody ahead of us in the queue? */
else if ( pThis->hNativeOwner == NIL_RTNATIVETHREAD
&& pThis->cWaiters == 0)
{
pThis->hNativeOwner = hNativeSelf;
pThis->cRecursions = 1;
}
/* Polling call? */
else if (cMillies == 0)
rc = VERR_TIMEOUT;
/* Yawn, time for a nap... */
else
{
rc = rtR0SemMutexDarwinRequestSleep(pThis, cMillies, fInterruptible, hNativeSelf);
IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
return rc;
}
lck_spin_unlock(pThis->pSpinlock);
IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
return rc;
}
开发者ID:miguelinux,项目名称:vbox,代码行数:60,代码来源:semmutex-r0drv-darwin.cpp
示例18: RTDECL
/**
* Adopts a non-IPRT thread.
*
* @returns IPRT status code.
* @param enmType The thread type.
* @param fFlags The thread flags. RTTHREADFLAGS_WAITABLE is not currently allowed.
* @param pszName The thread name. Optional.
* @param pThread Where to store the thread handle. Optional.
*/
RTDECL(int) RTThreadAdopt(RTTHREADTYPE enmType, unsigned fFlags, const char *pszName, PRTTHREAD pThread)
{
int rc;
RTTHREAD Thread;
AssertReturn(!(fFlags & RTTHREADFLAGS_WAITABLE), VERR_INVALID_PARAMETER);
AssertReturn(!pszName || VALID_PTR(pszName), VERR_INVALID_POINTER);
AssertReturn(!pThread || VALID_PTR(pThread), VERR_INVALID_POINTER);
rc = VINF_SUCCESS;
Thread = RTThreadSelf();
if (Thread == NIL_RTTHREAD)
{
/* generate a name if none was given. */
char szName[RTTHREAD_NAME_LEN];
if (!pszName || !*pszName)
{
static uint32_t s_i32AlienId = 0;
uint32_t i32Id = ASMAtomicIncU32(&s_i32AlienId);
RTStrPrintf(szName, sizeof(szName), "ALIEN-%RX32", i32Id);
pszName = szName;
}
/* try adopt it */
rc = rtThreadAdopt(enmType, fFlags, 0, pszName);
Thread = RTThreadSelf();
Log(("RTThreadAdopt: %RTthrd %RTnthrd '%s' enmType=%d fFlags=%#x rc=%Rrc\n",
Thread, RTThreadNativeSelf(), pszName, enmType, fFlags, rc));
}
else
Log(("RTThreadAdopt: %RTthrd %RTnthrd '%s' enmType=%d fFlags=%#x - already adopted!\n",
Thread, RTThreadNativeSelf(), pszName, enmType, fFlags));
if (pThread)
*pThread = Thread;
return rc;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:46,代码来源:thread.cpp
示例19: QComboBox
VBoxDbgConsoleInput::VBoxDbgConsoleInput(QWidget *pParent/* = NULL*/, const char *pszName/* = NULL*/)
: QComboBox(pParent), m_hGUIThread(RTThreadNativeSelf())
{
addItem(""); /* invariant: empty command line is the last item */
setEditable(true);
setInsertPolicy(NoInsert);
setAutoCompletion(false);
setMaxCount(50);
const QLineEdit *pEdit = lineEdit();
if (pEdit)
connect(pEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
NOREF(pszName);
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:15,代码来源:VBoxDbgConsole.cpp
示例20: LogFlow
SDLFramebuffer::~SDLFramebuffer()
{
LogFlow(("SDLFramebuffer::~SDLFramebuffer\n"));
RTCritSectDelete(&mUpdateLock);
AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
SDL_QuitSubSystem(SDL_INIT_VIDEO);
#ifdef VBOX_SECURELABEL
if (mLabelFont)
TTF_CloseFont(mLabelFont);
TTF_Quit();
#endif
mScreen = NULL;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:15,代码来源:SDLFramebuffer.cpp
注:本文中的RTThreadNativeSelf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论