JThread::JThread(int handle) : JReference(handle) { priority = fromPlatform( GetThreadPriority((HANDLE)handle)); ptarget = null; }
int CThread::GetPriority() const { #ifdef _WIN32 return GetThreadPriority(m_hThread); #elif _LINUX struct sched_param thread_param; int policy; pthread_getschedparam( m_threadId, &policy, &thread_param ); return thread_param.sched_priority; #endif }
void main_setRenderThreadPriority() { int prios[]={ GetThreadPriority(GetCurrentThread()), THREAD_PRIORITY_IDLE, THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_NORMAL, THREAD_PRIORITY_HIGHEST, }; SetThreadPriority(g_hThread,prios[cfg_render_prio]); }
static void MPOS_Start(void) { #if defined(RB_MSVC_WIN32) hApp = GetCurrentProcess(); hThread = GetCurrentThread(); iPriorityClass = GetPriorityClass(hApp); iPriority = GetThreadPriority(hThread); if (iPriorityClass != 0) SetPriorityClass(hApp, REALTIME_PRIORITY_CLASS); if (iPriority != THREAD_PRIORITY_ERROR_RETURN) SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); #elif defined(RB_MSVC_WINCE) hThread = GetCurrentThread(); iPriority = GetThreadPriority(hThread); if (iPriority != THREAD_PRIORITY_ERROR_RETURN) SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); #elif defined(RB_LINUX) iPriority = getpriority(PRIO_PROCESS, 0); //lazy to check error:p setpriority(PRIO_PROCESS, 0, -20); #else //backup & disable all IRQ except COM port's IRQ #endif }
/*----------------------------------------------------------------------*/ struct sys_timeouts * sys_arch_timeouts(void) { u8_t prio = GetThreadPriority(GetCurrentThread()); u8_t offset = prio - LWIP_START_PRIO; if (prio == THREAD_PRIORITY_ERROR_RETURN) { fprintf(stderr, "CreateThread failed with %d.\n", GetLastError()); return &lwip_timeouts[LWIP_TASK_MAX]; } if (offset >= 0 && offset < LWIP_TASK_MAX) return &lwip_timeouts[offset]; return &lwip_timeouts[LWIP_TASK_MAX]; }
UInt32 CAPThread::GetScheduledPriority() { #if TARGET_OS_MAC return CAPThread::getScheduledPriority( mPThread, CAPTHREAD_SCHEDULED_PRIORITY ); #elif TARGET_OS_WIN32 UInt32 theAnswer = 0; if(mThreadHandle != NULL) { theAnswer = GetThreadPriority(mThreadHandle); } return theAnswer; #endif }
/** 等待给出的线程结束. */ void mvg::synch::joinThread(const TThreadHandle &threadHandle) { if (threadHandle.isClear()) return; int prio = GetThreadPriority((HANDLE)threadHandle.hThread); if (THREAD_PRIORITY_ERROR_RETURN == prio) return; // 这边表示这个不是一个正在运行的线程 DWORD ret = WaitForSingleObject((HANDLE)threadHandle.hThread, INFINITE); if (ret != WAIT_OBJECT_0) std::cerr << "[mvg::synch::joinThread] Error waiting for thread completion!" << std::endl; }
pthread_t pthread_self (void) { pthread_t self; pthread_t nil = {NULL, 0}; ptw32_thread_t * sp; #if defined(_UWIN) if (!ptw32_selfThreadKey) return nil; #endif sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); if (sp != NULL) { self = sp->ptHandle; } else { self = ptw32_new (); sp = (ptw32_thread_t *) self.p; if (sp != NULL) { sp->implicit = 1; sp->detachState = PTHREAD_CREATE_DETACHED; sp->thread = GetCurrentThreadId (); #if defined(NEED_DUPLICATEHANDLE) sp->threadH = GetCurrentThread (); #else if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), GetCurrentProcess (), &sp->threadH, 0, FALSE, DUPLICATE_SAME_ACCESS)) { ptw32_threadReusePush (self); return nil; } #endif sp->sched_priority = GetThreadPriority (sp->threadH); pthread_setspecific (ptw32_selfThreadKey, (void *) sp); } } return (self); }
void CUI_LoadMsg::enter(void) { need_refresh = 1; load_finished = 0; // setWindowTitle("zt - loading file..."); SDL_WM_SetCaption("zt - [loading file]","zt - [loading file]"); OldPriority = GetThreadPriority(GetCurrentThread()); strtimer = strselect = 0; strtimer = SetTimer(NULL,strtimer,500,(TIMERPROC)TP_Load_Inc_Str); SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_BELOW_NORMAL); hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)load_thread,NULL,0,&iID); while(load_lock) { SDL_Delay(1); } }
bool CThread::WaitForThreadExit(unsigned int milliseconds) { bool bReturn = true; CSingleLock lock(m_CriticalSection); if (m_ThreadId && m_ThreadOpaque.handle != NULL) { // boost priority of thread we are waiting on to same as caller int callee = GetThreadPriority(m_ThreadOpaque.handle); int caller = GetThreadPriority(::GetCurrentThread()); if(caller != THREAD_PRIORITY_ERROR_RETURN && caller > callee) SetThreadPriority(m_ThreadOpaque.handle, caller); lock.Leave(); bReturn = m_TermEvent.WaitMSec(milliseconds); lock.Enter(); // restore thread priority if thread hasn't exited if(callee != THREAD_PRIORITY_ERROR_RETURN && caller > callee && m_ThreadOpaque.handle) SetThreadPriority(m_ThreadOpaque.handle, callee); } return bReturn; }
void EvalPriorityExpand(const void *data, qCtx *ctx, qStr *out, qArgAry *args) { if (ctx->GetSafeMode()) {ctx->Throw(out, 301, "function not available"); return;} int priority = THREAD_PRIORITY_ERROR_RETURN; CStr pname = (*args)[0]; if (!stricmp(pname,"low")) { priority = THREAD_PRIORITY_BELOW_NORMAL; } if (!stricmp(pname,"high")) { priority = THREAD_PRIORITY_ABOVE_NORMAL; } if (!stricmp(pname,"normal")) { priority = THREAD_PRIORITY_NORMAL; } if (!stricmp(pname,"lowest")) { priority = THREAD_PRIORITY_LOWEST; } if (!stricmp(pname,"highest")) { priority = THREAD_PRIORITY_HIGHEST; } if (priority == THREAD_PRIORITY_ERROR_RETURN) ctx->Throw(out, 353, "Priority must be one of low, high, normal, lowest, highest"); else { DWORD was = GetThreadPriority(GetCurrentThread()); SetThreadPriority(GetCurrentThread(), priority); try { ctx->Parse(args->GetAt(1),out); } catch (qCtxExAbort ex) { SetThreadPriority(GetCurrentThread(), was); throw ex; } catch (qCtxEx ex) { SetThreadPriority(GetCurrentThread(), was); throw ex; } catch (...) { qCtxEx ex(354, "Unknown exception during priority shift"); SetThreadPriority(GetCurrentThread(), was); throw ex; } SetThreadPriority(GetCurrentThread(), was); } }
//-------------------------------------------------------------------- // ThreadProc() - 本例之 5 個 threads 共用之 thread procedure //-------------------------------------------------------------------- VOID ThreadProc(DWORD *ThreadArg) { RECT rect; HDC hDC; HANDLE hBrush, hOldBrush; DWORD dwThreadHits = 0; char cBuf[80]; int iThreadNo, i; GetClientRect (_hWnd, &rect); hDC = GetDC (_hWnd); hBrush = CreateSolidBrush(RGB(*(ThreadArg), *(ThreadArg), *(ThreadArg))); // 變化畫刷顏色 hOldBrush = SelectObject(hDC, hBrush); switch (*ThreadArg) { case HIGHEST_THREAD : iThreadNo = 0; break; case ABOVE_AVE_THREAD : iThreadNo = 1; break; case NORMAL_THREAD : iThreadNo = 2; break; case BELOW_AVE_THREAD : iThreadNo = 3; break; case LOWEST_THREAD : iThreadNo = 4; break; } // 顯示 thread 號碼及其優先權 (priority) wsprintf(cBuf, "T%d", iThreadNo); TextOut(hDC, *(ThreadArg), rect.bottom-150, cBuf, lstrlen(cBuf)); wsprintf(cBuf, "P=%d", GetThreadPriority(_hThread[iThreadNo])); TextOut(hDC, *(ThreadArg), rect.bottom-130, cBuf, lstrlen(cBuf)); do { dwThreadHits++; // 計數器 // 畫出四方形,代表 thread 的進行 Rectangle(hDC, *(ThreadArg), rect.bottom-(dwThreadHits/10), *(ThreadArg)+0x40, rect.bottom); // 延遲... if (_uDelayType == SLEEPDELAY) Sleep(10); else if (_uDelayType == FORLOOPDELAY) for (i=0; i<30000; i++); else // _uDelayType == NODELAY) { } } while (dwThreadHits < 1000); // 巡迴 1000 次 hBrush = SelectObject(hDC, hOldBrush); // 恢復畫刷顏色 DeleteObject (hBrush); ReleaseDC (_hWnd, hDC); }
/** * Initialize a thread's priority. * * Here the threading library priority value is converted to the appropriate * OS-specific value. * * @param[in] thread a thread * @return none * */ void initialize_thread_priority(omrthread_t thread) { int priority; thread->priority = J9THREAD_PRIORITY_NORMAL; if (priority_map[J9THREAD_PRIORITY_MIN] == priority_map[J9THREAD_PRIORITY_MAX]) { return; } priority = GetThreadPriority(thread->handle); thread->priority = omrthread_map_native_priority(priority); }
int pthread_getschedparam(pthread_t thread, int* policy, struct sched_param* param) { if(policy) { DWORD pc = GetPriorityClass(GetCurrentProcess()); *policy = (pc >= HIGH_PRIORITY_CLASS)? SCHED_FIFO : SCHED_RR; } if(param) { const HANDLE hThread = HANDLE_from_pthread(thread); param->sched_priority = GetThreadPriority(hThread); } return 0; }
ThreadPriority::Enum ThreadImpl::getPriority(Id threadId) { ThreadPriority::Enum retval = ThreadPriority::eLOW; int priority = GetThreadPriority((HANDLE)threadId); NV_COMPILE_TIME_ASSERT(THREAD_PRIORITY_HIGHEST > THREAD_PRIORITY_ABOVE_NORMAL); if(priority >= THREAD_PRIORITY_HIGHEST) retval = ThreadPriority::eHIGH; else if(priority >= THREAD_PRIORITY_ABOVE_NORMAL) retval = ThreadPriority::eABOVE_NORMAL; else if(priority >= THREAD_PRIORITY_NORMAL) retval = ThreadPriority::eNORMAL; else if(priority >= THREAD_PRIORITY_BELOW_NORMAL) retval = ThreadPriority::eBELOW_NORMAL; return retval; }
ThreadPriority HThread::GetPriority() const { Int iWinPriority = GetThreadPriority( m_hThreadingObject ); DebugAssert( iWinPriority != THREAD_PRIORITY_ERROR_RETURN ); switch( iWinPriority ) { case THREAD_PRIORITY_IDLE: return THREAD_PRIORITY_IDLETIME; case THREAD_PRIORITY_LOWEST: return THREAD_PRIORITY_VERYLOW; case THREAD_PRIORITY_BELOW_NORMAL: return THREAD_PRIORITY_LOW; case THREAD_PRIORITY_NORMAL: return THREAD_PRIORITY_DEFAULT; case THREAD_PRIORITY_ABOVE_NORMAL: return THREAD_PRIORITY_HIGH; case THREAD_PRIORITY_HIGHEST: return THREAD_PRIORITY_VERYHIGH; case THREAD_PRIORITY_TIME_CRITICAL: return THREAD_PRIORITY_REALTIME; default: DebugAssert( false ); return THREAD_PRIORITY_DEFAULT; } }
//========================================================================= // Internal function: // // Resumes all previously suspended threads in the current process. //========================================================================= static VOID ResumeOtherThreads() { // make sure things go as fast as possible INT nOriginalPriority = GetThreadPriority(GetCurrentThread()); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); // go through our list for (DWORD i=0; i<g_nThreadHandles; i++) { // and resume & close thread handles ResumeThread(g_hThreadHandles[i]); CloseHandle(g_hThreadHandles[i]); } // clean up free(g_hThreadHandles); g_hThreadHandles = NULL; g_nThreadHandles = 0; SetThreadPriority(GetCurrentThread(), nOriginalPriority); }
//--------------------------------------------------------------------------- tTVPThreadPriority tTVPThread::GetPriority() { int n = GetThreadPriority(Handle); switch(n) { case THREAD_PRIORITY_IDLE: return ttpIdle; case THREAD_PRIORITY_LOWEST: return ttpLowest; case THREAD_PRIORITY_BELOW_NORMAL: return ttpLower; case THREAD_PRIORITY_NORMAL: return ttpNormal; case THREAD_PRIORITY_ABOVE_NORMAL: return ttpHigher; case THREAD_PRIORITY_HIGHEST: return ttpHighest; case THREAD_PRIORITY_TIME_CRITICAL: return ttpTimeCritical; } return ttpNormal; }
zactor_t * zactor_new (zactor_fn *actor, void *args) { zactor_t *self = (zactor_t *) zmalloc (sizeof (zactor_t)); if (!self) return NULL; self->tag = ZACTOR_TAG; shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t)); if (!shim) { zactor_destroy (&self); return NULL; } shim->pipe = zsys_create_pipe (&self->pipe); shim->handler = actor; shim->args = args; #if defined (__UNIX__) pthread_t thread; pthread_create (&thread, NULL, s_thread_shim, shim); pthread_detach (thread); #elif defined (__WINDOWS__) HANDLE handle = (HANDLE) _beginthreadex ( NULL, // Handle is private to this process 0, // Use a default stack size for new thread &s_thread_shim, // Start real thread function via this shim shim, // Which gets arguments shim CREATE_SUSPENDED, // Set thread priority before starting it NULL); // We don't use the thread ID assert (handle); // Set child thread priority to same as current int priority = GetThreadPriority (GetCurrentThread ()); SetThreadPriority (handle, priority); // Start thread & release resources ResumeThread (handle); CloseHandle (handle); #endif // Mandatory handshake for new actor so that constructor returns only // when actor has also initialized. This eliminates timing issues at // application start up. zsock_wait (self->pipe); return self; }
L0040159C( intOrPtr __edi // r4 ) { intOrPtr _v80; // _cfa_ffffffb0 intOrPtr _v156; // _cfa_ffffff64 signed int _v236; // _cfa_ffffff14 _unknown_ __ebp; // r6 _unknown_ _t12; // _t12 _unknown_ _t13; // _t13 _unknown_ _t14; // _t14 intOrPtr _t15; // _t15 _unknown_ _t16; // _t16 _unknown_ _t17; // _t17 _unknown_ _t18; // _t18 _t15 = __edi; _push(_t17); _t18 = __esp; __esp = __esp - 256; __edx = __ebx + 244; *((intOrPtr*)(__edx + -144)) = _t15; _v156 = -386605051; _push(__edx); GetActiveWindow(); _pop(__edx); _v80 = 5; while(1) { asm("sbb esi, edi"); _v80 = _v80 - 1; if(_v80 == 0) { break; } } _push(__edx); _push(_t15); _push( *((intOrPtr*)(__edx + 1208))); L00401950(); _pop(__edx); _v236 = _v236 | -46; _push(__edx); GetThreadPriority(-2); _pop(__edx); __esp = _t18; _pop(__ebp); return; }
int tMPI_Thread_create(tMPI_Thread_t *thread, void *(*start_routine)(void *), void *arg) { DWORD thread_id; struct tMPI_Thread_starter_param *prm; tMPI_Init_initers(); /* a small memory leak to be sure that it doesn't get deallocated once this function ends, before the newly created thread uses it. */ prm=(struct tMPI_Thread_starter_param*) tMPI_Malloc(sizeof(struct tMPI_Thread_starter_param)); prm->start_routine= start_routine; prm->param=arg; *thread=(struct tMPI_Thread*)tMPI_Malloc(sizeof(struct tMPI_Thread)*1); if(thread==NULL) { tMPI_Fatal_error(TMPI_FARGS,"Invalid thread pointer."); return EINVAL; } /* just create a plain thread. */ (*thread)->th = CreateThread(NULL, 0, tMPI_Win32_thread_starter, prm, 0, &thread_id); if((*thread)->th==NULL) { tMPI_Free(thread); tMPI_Fatal_error(TMPI_FARGS,"Failed to create thread, error code=%d", GetLastError()); return -1; } /* inherit the thread priority from the parent thread. */ /* TODO: is there value in setting this, vs. just allowing it to default from the process? currently, this limits the effectivenes of changing the priority in eg: TaskManager. */ SetThreadPriority(((*thread)->th), GetThreadPriority(GetCurrentThread())); return 0; }
double performance_measure(F f) { unsigned count = 1; double time, result; #ifdef _WIN32 int old_priority = GetThreadPriority(GetCurrentThread()); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); #endif // // Begin by figuring out how many times to repeat // the function call in order to get a measureable time: // do { boost::timer t; for(unsigned i = 0; i < count; ++i) f(); time = t.elapsed(); count *= 2; t.restart(); }while(time < 0.5); count /= 2; result = time; // // Now repeat the measurement over and over // and take the shortest measured time as the // result, generally speaking this gives us // consistent results: // for(unsigned i = 0; i < 20u;++i) { boost::timer t; for(unsigned i = 0; i < count; ++i) f(); time = t.elapsed(); if(time < result) result = time; t.restart(); } #ifdef _WIN32 SetThreadPriority(GetCurrentThread(), old_priority); #endif return result / count; }
int ThreadGetPriority(void* Thread) { int v = GetThreadPriority(Thread); #if defined(TARGET_WINCE) v = v - THREAD_PRIORITY_NORMAL; #else v = THREAD_PRIORITY_NORMAL - v; #endif if (v>1) return MULTITHREAD_PRIORITY_IDLE; if (v==1) return MULTITHREAD_PRIORITY_LOW; if (v==0) return MULTITHREAD_PRIORITY_NORMAL; if (v==-1) return MULTITHREAD_PRIORITY_USERINPUT; return MULTITHREAD_PRIORITY_HIGH; }
int zThread::getPriority() const { #if defined(_WIN32) || defined(_WIN64) zMutexLock m1(&m_zThread); if(pid > 0) return GetThreadPriority(hThread); return 0; #else #if defined(__GNUG__) || defined(__linux__) || defined(__CYGWIN__) #ifndef __CYGWIN__ zMutexLock m1(&m_zThread); if(pid > 0) return getpriority(PRIO_PROCESS,pid); return 0; #else return 1; #endif #endif #endif }
int main() { pthread_t t; pthread_attr_t attr; void * result = NULL; struct sched_param param; assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1); assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1); assert(pthread_create(&t, NULL, getValidPriorities, NULL) == 0); assert(pthread_join(t, &result) == 0); assert(pthread_attr_init(&attr) == 0); assert(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0); /* Set the thread's priority to a known initial value. */ SetThreadPriority(pthread_getw32threadhandle_np(pthread_self()), PTW32TEST_THREAD_INIT_PRIO); printf("Using pthread_getschedparam\n"); printf("%10s %10s %10s\n", "Set value", "Get value", "Win priority"); for (param.sched_priority = minPrio; param.sched_priority <= maxPrio; param.sched_priority++) { int prio; assert(pthread_attr_setschedparam(&attr, ¶m) == 0); assert(pthread_create(&t, &attr, func, (void *) &attr) == 0); assert((prio = GetThreadPriority(pthread_getw32threadhandle_np(t))) == validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]); assert(pthread_join(t, &result) == 0); assert(param.sched_priority == (int)(size_t) result); printf("%10d %10d %10d\n", param.sched_priority, (int)(size_t) result, prio); } return 0; }
int test_priority2(void) #endif { pthread_t t; void * result = NULL; int result2; struct sched_param param; assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1); assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1); assert(pthread_create(&t, NULL, getValidPriorities, NULL) == 0); assert(pthread_join(t, &result) == 0); assert(pthread_barrier_init(&startBarrier, NULL, 2) == 0); assert(pthread_barrier_init(&endBarrier, NULL, 2) == 0); /* Set the thread's priority to a known initial value. * If the new priority is invalid then the threads priority * is unchanged from the previous value. */ SetThreadPriority(pthread_getw32threadhandle_np(pthread_self()), PTW32TEST_THREAD_INIT_PRIO); for (param.sched_priority = minPrio; param.sched_priority <= maxPrio; param.sched_priority++) { assert(pthread_create(&t, NULL, func, NULL) == 0); assert(pthread_setschedparam(t, SCHED_OTHER, ¶m) == 0); result2 = pthread_barrier_wait(&startBarrier); assert(result2 == 0 || result2 == PTHREAD_BARRIER_SERIAL_THREAD); result2 = pthread_barrier_wait(&endBarrier); assert(result2 == 0 || result2 == PTHREAD_BARRIER_SERIAL_THREAD); assert(GetThreadPriority(pthread_getw32threadhandle_np(t)) == validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]); pthread_join(t, &result); assert(param.sched_priority == (int)(size_t)result); } return 0; }
void osd_sleep(osd_ticks_t duration) { #ifdef WIN32 DWORD msec; // make sure we've computed ticks_per_second if (ticks_per_second == 0) (void)osd_ticks(); // convert to milliseconds, rounding down msec = (DWORD)(duration * 1000 / ticks_per_second); // only sleep if at least 2 full milliseconds if (msec >= 2) { HANDLE current_thread = GetCurrentThread(); int old_priority = GetThreadPriority(current_thread); // take a couple of msecs off the top for good measure msec -= 2; // bump our thread priority super high so that we get // priority when we need it SetThreadPriority(current_thread, THREAD_PRIORITY_TIME_CRITICAL); Sleep(msec); SetThreadPriority(current_thread, old_priority); } #else UINT32 msec; // convert to milliseconds, rounding down msec = (UINT32)(duration * 1000 / osd_ticks_per_second()); // only sleep if at least 2 full milliseconds if (msec >= 2) { // take a couple of msecs off the top for good measure msec -= 2; usleep(msec*1000); } #endif }
static void getCurrentOsSched(int *priority, int *policy) { #if defined(SPEC_PTHREAD_API) && !defined(J9ZOS390) OSTHREAD tid = pthread_self(); struct sched_param param; PTHREAD_VERBOSE(pthread_getschedparam(tid, policy, ¶m)); *priority = param.sched_priority; #elif defined(SPEC_WIN_API) OSTHREAD tid = GetCurrentThread(); *priority = GetThreadPriority(tid); *policy = -1; #else *priority = -1; *policy = -1; #endif /* defined(SPEC_PTHREAD_API) */ }
QWaitConditionEvent *QWaitConditionPrivate::pre() { mtx.lock(); QWaitConditionEvent *wce = freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst(); wce->priority = GetThreadPriority(GetCurrentThread()); wce->wokenUp = false; // insert 'wce' into the queue (sorted by priority) int index = 0; for (; index < queue.size(); ++index) { QWaitConditionEvent *current = queue.at(index); if (current->priority < wce->priority) break; } queue.insert(index, wce); mtx.unlock(); return wce; }
INT64 RDTSCTimer::calcTicksPerSecond() { // raise the priority for accurate timing int priClass = GetPriorityClass(GetCurrentProcess()); SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); int priority = GetThreadPriority(GetCurrentThread()); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); // wait for 0.25 seconds INT64 begin = RDTSCTimer::getTime(); Sleep(1000/4); INT64 end = RDTSCTimer::getTime(); // restore the previous priority SetPriorityClass(GetCurrentProcess(), priClass); SetThreadPriority(GetCurrentThread(), priority); return (end - begin)*4; }