Changeset 25427 in vbox for trunk/src/VBox/Runtime/r0drv/linux/timer-r0drv-linux.c
- Timestamp:
- Dec 16, 2009 1:44:58 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56075
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/timer-r0drv-linux.c
r24181 r25427 48 48 #include "internal/magics.h" 49 49 50 /* We use the API of Linux 2.6.28+ (hrtimer_add_expires_ns()) */ 50 51 #if !defined(RT_USE_LINUX_HRTIMER) \ 51 && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2 3) \52 && 0 /* disabled because it somehow sucks.*/52 && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) \ 53 && 0 /* currently disabled */ 53 54 # define RT_USE_LINUX_HRTIMER 54 55 #endif … … 56 57 /* This check must match the ktime usage in rtTimeGetSystemNanoTS() / time-r0drv-linux.c. */ 57 58 #if defined(RT_USE_LINUX_HRTIMER) \ 58 && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)59 # error "RT_USE_LINUX_HRTIMER requires 2.6. 16or later, sorry."59 && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) 60 # error "RT_USE_LINUX_HRTIMER requires 2.6.28 or later, sorry." 60 61 #endif 61 62 … … 99 100 #else 100 101 struct timer_list LnxTimer; 101 #endif102 102 /** The start of the current run (ns). 103 103 * This is used to calculate when the timer ought to fire the next time. */ … … 106 106 * This is used to calculate when the timer ought to fire the next time. */ 107 107 uint64_t u64NextTS; 108 #endif 108 109 /** The current tick number (since u64StartTS). */ 109 110 uint64_t iTick; … … 250 251 if (cNanoSecs > (uint64_t)TICK_NSEC * MAX_JIFFY_OFFSET) 251 252 return MAX_JIFFY_OFFSET; 252 # if ARCH_BITS == 32253 # if ARCH_BITS == 32 253 254 if (RT_LIKELY(cNanoSecs <= UINT32_MAX)) 254 255 return ((uint32_t)cNanoSecs + (TICK_NSEC-1)) / TICK_NSEC; 255 # endif256 # endif 256 257 return (cNanoSecs + (TICK_NSEC-1)) / TICK_NSEC; 257 258 } 258 #endif 259 #endif /* ! RT_USE_LINUX_HRTIMER */ 259 260 260 261 … … 272 273 */ 273 274 uint64_t u64NextTS = u64Now + u64First; 275 #ifndef RT_USE_LINUX_HRTIMER 274 276 pSubTimer->u64StartTS = u64NextTS; 275 277 pSubTimer->u64NextTS = u64NextTS; 278 #endif 279 276 280 pSubTimer->iTick = 0; 277 281 … … 368 372 else 369 373 { 374 const uint64_t iTick = ++pSubTimer->iTick; 375 376 #ifdef RT_USE_LINUX_HRTIMER 377 hrtimer_add_expires_ns(&pSubTimer->LnxTimer, pTimer->u64NanoInterval); 378 rc = HRTIMER_RESTART; 379 #else 380 const uint64_t u64NanoTS = RTTimeNanoTS(); 381 370 382 /* 371 383 * Interval timer, calculate the next timeout and re-arm it. … … 375 387 * This may of course backfire with highres timers... 376 388 */ 377 const uint64_t u64NanoTS = RTTimeNanoTS();378 const uint64_t iTick = ++pSubTimer->iTick;379 380 389 if (RT_UNLIKELY(iTick == 1)) 381 390 { 382 #ifdef RT_USE_LINUX_HRTIMER383 pSubTimer->u64StartTS = pSubTimer->u64NextTS = u64NanoTS;//rtTimerLnxKtToNano(pSubTimer->LnxTimer.base->softirq_time);384 #else385 391 pSubTimer->u64StartTS = pSubTimer->u64NextTS = u64NanoTS; 386 392 pSubTimer->ulNextJiffies = jiffies; 387 #endif388 393 } 389 394 390 395 pSubTimer->u64NextTS += pTimer->u64NanoInterval; 391 392 #ifdef RT_USE_LINUX_HRTIMER393 while (pSubTimer->u64NextTS < u64NanoTS)394 pSubTimer->u64NextTS += pTimer->u64NanoInterval;395 396 pSubTimer->LnxTimer.expires = rtTimerLnxNanoToKt(pSubTimer->u64NextTS);397 rc = HRTIMER_RESTART;398 #else399 396 if (pTimer->cJiffies) 400 397 { … … 896 893 pTimer->aSubTimers[iCpu].LnxTimer.function = rtTimerLinuxCallback; 897 894 pTimer->aSubTimers[iCpu].LnxTimer.expires = jiffies; 898 #endif899 895 pTimer->aSubTimers[iCpu].u64StartTS = 0; 900 896 pTimer->aSubTimers[iCpu].u64NextTS = 0; 897 #endif 901 898 pTimer->aSubTimers[iCpu].iTick = 0; 902 899 pTimer->aSubTimers[iCpu].pParent = pTimer;
Note:
See TracChangeset
for help on using the changeset viewer.