Changeset 54512 in vbox
- Timestamp:
- Feb 25, 2015 7:06:07 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/timer.h
r54208 r54512 145 145 * 146 146 * @returns iprt status code. 147 * @retval VERR_WRONG_CONTEXT if executing at the wrong IRQL (windows), PIL 148 * (solaris), or similar. Portable code does not destroy timers with 149 * preemption (or interrupts) disabled. 147 150 * @param pTimer Timer to stop and destroy. NULL is ok. 148 151 */ -
trunk/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp
r53457 r54512 36 36 #include <iprt/asm.h> 37 37 #include <iprt/assert.h> 38 #include <iprt/alloc.h> 38 #include <iprt/mem.h> 39 #include <iprt/thread.h> 39 40 40 41 #include "internal-r0drv-nt.h" … … 59 60 /** Pointer to the parent timer. */ 60 61 PRTTIMER pParent; 62 /** Thread active executing the worker function, NIL if inactive. */ 63 RTNATIVETHREAD volatile hActiveThread; 61 64 /** The NT DPC object. */ 62 65 KDPC NtDpc; … … 187 190 && pTimer->u32Magic == RTTIMER_MAGIC) 188 191 { 192 ASMAtomicWriteHandle(&pTimer->aSubTimers[0].hActiveThread, RTThreadNativeSelf()); 193 189 194 if (!pTimer->u64NanoInterval) 190 195 ASMAtomicWriteBool(&pTimer->fSuspended, true); … … 193 198 rtTimerNtRearmInternval(pTimer, iTick, &pTimer->aSubTimers[0].NtDpc); 194 199 pTimer->pfnTimer(pTimer, pTimer->pvUser, iTick); 200 201 ASMAtomicWriteHandle(&pTimer->aSubTimers[0].hActiveThread, NIL_RTNATIVETHREAD); 195 202 } 196 203 … … 227 234 && pTimer->u32Magic == RTTIMER_MAGIC) 228 235 { 236 ASMAtomicWriteHandle(&pSubTimer->hActiveThread, RTThreadNativeSelf()); 237 229 238 if (!pTimer->u64NanoInterval) 230 239 if (ASMAtomicDecS32(&pTimer->cOmniSuspendCountDown) <= 0) … … 232 241 233 242 pTimer->pfnTimer(pTimer, pTimer->pvUser, ++pSubTimer->iTick); 243 244 ASMAtomicWriteHandle(&pSubTimer->hActiveThread, NIL_RTNATIVETHREAD); 234 245 } 235 246 … … 272 283 RTCPUSET OnlineSet; 273 284 RTMpGetOnlineSet(&OnlineSet); 285 286 ASMAtomicWriteHandle(&pSubTimer->hActiveThread, RTThreadNativeSelf()); 274 287 275 288 if (pTimer->u64NanoInterval) … … 309 322 pTimer->pfnTimer(pTimer, pTimer->pvUser, ++pSubTimer->iTick); 310 323 } 324 325 ASMAtomicWriteHandle(&pSubTimer->hActiveThread, NIL_RTNATIVETHREAD); 311 326 } 312 327 … … 379 394 */ 380 395 ASMAtomicWriteBool(&pTimer->fSuspended, true); 396 381 397 KeCancelTimer(&pTimer->NtTimer); 382 398 383 399 for (RTCPUID iCpu = 0; iCpu < pTimer->cSubTimers; iCpu++) 384 400 KeRemoveQueueDpc(&pTimer->aSubTimers[iCpu].NtDpc); 385 386 /*387 * I'm a bit uncertain whether this should be done during RTTimerStop388 * or only in RTTimerDestroy()... Linux and Solaris will wait AFAIK,389 * which is why I'm keeping this here for now.390 */391 if (g_pfnrtNtKeFlushQueuedDpcs)392 g_pfnrtNtKeFlushQueuedDpcs();393 401 } 394 402 … … 431 439 432 440 /* 441 * We do not support destroying a timer from the callback because it is 442 * not 101% safe since we cannot flush DPCs. Solaris has the same restriction. 443 */ 444 AssertReturn(KeGetCurrentIrql() == PASSIVE_LEVEL, VERR_INVALID_CONTEXT); 445 446 /* 433 447 * Invalidate the timer, stop it if it's running and finally 434 448 * free up the memory. … … 437 451 if (!ASMAtomicUoReadBool(&pTimer->fSuspended)) 438 452 rtTimerNtStopWorker(pTimer); 453 454 /* 455 * Flush DPCs to be on the safe side. 456 */ 457 if (g_pfnrtNtKeFlushQueuedDpcs) 458 g_pfnrtNtKeFlushQueuedDpcs(); 459 439 460 RTMemFree(pTimer); 440 461 -
trunk/src/VBox/Runtime/testcase/tstRTR0Timer.cpp
r54189 r54512 520 520 #endif 521 521 522 #if !defined(RT_OS_SOLARIS) /* Not expected to work on all hosts. */522 #if !defined(RT_OS_SOLARIS) && !defined(RT_OS_WINDOWS) /* Not expected to work on all hosts. */ 523 523 case TSTRTR0TIMER_ONE_SHOT_DESTROY: 524 524 case TSTRTR0TIMER_ONE_SHOT_DESTROY_HIRES:
Note:
See TracChangeset
for help on using the changeset viewer.