Changeset 39910 in vbox
- Timestamp:
- Jan 30, 2012 4:05:58 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r39877 r39910 1543 1543 # define RTTimerLRStart RT_MANGLER(RTTimerLRStart) 1544 1544 # define RTTimerLRStop RT_MANGLER(RTTimerLRStop) 1545 # define RTTimerLRChangeInterval RT_MANGLER(RTTimerLRChangeInterval) 1545 1546 # define RTTimerReleaseSystemGranularity RT_MANGLER(RTTimerReleaseSystemGranularity) /* r0drv */ 1546 1547 # define RTTimerRequestSystemGranularity RT_MANGLER(RTTimerRequestSystemGranularity) /* r0drv */ -
trunk/include/iprt/timer.h
r32572 r39910 355 355 RTDECL(int) RTTimerLRStop(RTTIMERLR hTimerLR); 356 356 357 /** 358 * Changes the interval of a low resolution timer. 359 * 360 * If the timer is active, the next tick will occure immediately just like with 361 * RTTimerLRStart() when u64First parameter is zero. 362 * 363 * @returns IPRT status code. 364 * @retval VERR_INVALID_HANDLE if pTimer isn't valid. 365 * @retval VERR_NOT_SUPPORTED if not supported. 366 * 367 * @param hTimerLR The low resolution timer to update. 368 * @param u64NanoInterval The interval between timer ticks specified in 369 * nanoseconds. This is rounded to the fit the 370 * system timer granularity. 371 * @remarks Callable from the timer callback. 372 */ 373 RTDECL(int) RTTimerLRChangeInterval(RTTIMERLR hTimerLR, uint64_t u64NanoInterval); 374 357 375 /** @} */ 358 376 -
trunk/src/VBox/Runtime/generic/timerlr-generic.cpp
r39083 r39910 236 236 RT_EXPORT_SYMBOL(RTTimerLRStop); 237 237 238 RTDECL(int) RTTimerLRChangeInterval(RTTIMERLR hTimerLR, uint64_t u64NanoInterval) 239 { 240 PRTTIMERLRINT pThis = hTimerLR; 241 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 242 AssertReturn(pThis->u32Magic == RTTIMERLR_MAGIC, VERR_INVALID_HANDLE); 243 AssertReturn(!pThis->fDestroyed, VERR_INVALID_HANDLE); 244 245 if (u64NanoInterval && u64NanoInterval < 100*1000*1000) 246 return VERR_INVALID_PARAMETER; 247 248 #if 0 249 if (!pThis->fSuspended) 250 { 251 int rc = RTTimerLRStop(hTimerLR); 252 if (RT_FAILURE(rc)) 253 return rc; 254 255 ASMAtomicWriteU64(&pThis->u64NanoInterval, u64NanoInterval); 256 257 rc = RTTimerLRStart(hTimerLR, 0); 258 if (RT_FAILURE(rc)) 259 return rc; 260 } 261 else 262 #endif 263 { 264 uint64_t u64Now = RTTimeNanoTS(); 265 ASMAtomicWriteU64(&pThis->iTick, 0); 266 ASMAtomicWriteU64(&pThis->u64StartTS, u64Now); 267 ASMAtomicWriteU64(&pThis->u64NextTS, u64Now); 268 ASMAtomicWriteU64(&pThis->u64NanoInterval, u64NanoInterval); 269 int rc = RTSemEventSignal(pThis->hEvent); 270 } 271 272 return VINF_SUCCESS; 273 } 274 RT_EXPORT_SYMBOL(RTTimerLRChangeInterval); 238 275 239 276 static DECLCALLBACK(int) rtTimerLRThread(RTTHREAD hThreadSelf, void *pvUser) -
trunk/src/VBox/Runtime/testcase/tstTimerLR.cpp
r38636 r39910 206 206 207 207 /* 208 * Test changing the interval dynamically 209 */ 210 RTPrintf("\n" 211 "tstTimer: Testing dynamic changes of timer interval...\n"); 212 do 213 { 214 RTTIMERLR hTimerLR; 215 rc = RTTimerLRCreateEx(&hTimerLR, aTests[0].uMilliesInterval * (uint64_t)1000000, 0, TimerLRCallback, NULL); 216 if (RT_FAILURE(rc)) 217 { 218 RTPrintf("RTTimerLRCreateEX(,%u*1M,,,) -> %d\n", aTests[i].uMilliesInterval, rc); 219 cErrors++; 220 continue; 221 } 222 223 for (i = 0; i < RT_ELEMENTS(aTests); i++) 224 { 225 RTPrintf("\n" 226 "tstTimer: TESTING - %d ms interval, %d ms wait, expects %d-%d ticks.\n", 227 aTests[i].uMilliesInterval, aTests[i].uMilliesWait, aTests[i].cLower, aTests[i].cUpper); 228 229 gcTicks = 0; 230 gu64Max = 0; 231 gu64Min = UINT64_MAX; 232 gu64Prev = 0; 233 /* 234 * Start the timer an actively wait for it for the period requested. 235 */ 236 uTSBegin = RTTimeNanoTS(); 237 if (i == 0) 238 { 239 rc = RTTimerLRStart(hTimerLR, 0); 240 if (RT_FAILURE(rc)) 241 { 242 RTPrintf("tstTimer: FAILURE - RTTimerLRStart() -> %Rrc\n", rc); 243 cErrors++; 244 } 245 } 246 else 247 { 248 rc = RTTimerLRChangeInterval(hTimerLR, aTests[i].uMilliesInterval * (uint64_t)1000000); 249 if (RT_FAILURE(rc)) 250 { 251 RTPrintf("tstTimer: FAILURE - RTTimerLRChangeInterval() -> %d gcTicks=%d\n", rc, gcTicks); 252 cErrors++; 253 } 254 } 255 256 while (RTTimeNanoTS() - uTSBegin < (uint64_t)aTests[i].uMilliesWait * 1000000) 257 /* nothing */; 258 259 uint64_t uTSEnd = RTTimeNanoTS(); 260 uTSDiff = uTSEnd - uTSBegin; 261 RTPrintf("uTS=%RI64 (%RU64 - %RU64)\n", uTSDiff, uTSBegin, uTSEnd); 262 263 /* 264 * Check the number of ticks. 265 */ 266 if (gcTicks < aTests[i].cLower) 267 { 268 RTPrintf("tstTimer: FAILURE - Too few ticks gcTicks=%d (expected %d-%d)\n", gcTicks, aTests[i].cUpper, aTests[i].cLower); 269 cErrors++; 270 } 271 else if (gcTicks > aTests[i].cUpper) 272 { 273 RTPrintf("tstTimer: FAILURE - Too many ticks gcTicks=%d (expected %d-%d)\n", gcTicks, aTests[i].cUpper, aTests[i].cLower); 274 cErrors++; 275 } 276 else 277 RTPrintf("tstTimer: OK - gcTicks=%d\n", gcTicks); 278 // RTPrintf(" min=%RU64 max=%RU64\n", gu64Min, gu64Max); 279 } 280 /* don't stop it, destroy it because there are potential races in destroying an active timer. */ 281 rc = RTTimerLRDestroy(hTimerLR); 282 if (RT_FAILURE(rc)) 283 { 284 RTPrintf("tstTimer: FAILURE - RTTimerLRDestroy() -> %d gcTicks=%d\n", rc, gcTicks); 285 cErrors++; 286 } 287 } while (0); 288 289 /* 208 290 * Test multiple timers running at once. 209 291 */
Note:
See TracChangeset
for help on using the changeset viewer.