本文整理汇总了C++中RTThreadNativeSelf函数的典型用法代码示例。如果您正苦于以下问题:C++ RTThreadNativeSelf函数的具体用法?C++ RTThreadNativeSelf怎么用?C++ RTThreadNativeSelf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTThreadNativeSelf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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()));
}
示例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();
}
示例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)
示例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 */
}
示例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);
}
}
示例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;
}