- Timestamp:
- Oct 24, 2010 2:57:44 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h
r33381 r33384 36 36 #include <iprt/time.h> 37 37 38 /** The resolution (nanoseconds) specified when using39 * schedule_hrtimeout_range. */40 #define RTR0SEMLNXWAIT_RESOLUTION 5000041 42 43 38 /** 44 39 * Kernel mode Linux wait state structure. … … 46 41 typedef struct RTR0SEMBSDSLEEP 47 42 { 43 /** The absolute timeout given as nano seconds since the start of the 44 * monotonic clock. */ 45 uint64_t uNsAbsTimeout; 48 46 /** The timeout in ticks. Updated after waiting. */ 49 47 int iTimeout; … … 65 63 66 64 /** 65 * Updates the timeout of the FreeBSD wait. 66 * 67 * @returns RTSEMWAIT_FLAGS_INDEFINITE if the timeout value is too big. 68 * 0 otherwise 69 * @param pWait The wait structure. 70 * @param uTimeout The relative timeout in nanoseconds. 71 */ 72 DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0SEMBSDSLEEP pWait, uint64_t uTimeout) 73 { 74 #if 0 75 struct timeval tv; 76 77 tv.tv_sec = uTimeout / UINT64_C(1000000000); 78 tv.tv_usec = (uTimeout % UINT64_C(1000000000)) / UINT64_C(1000); 79 80 pWait->iTimeout = tvtohz(&tv); 81 #else 82 uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000)); 83 if (cTicks >= INT_MAX) 84 return RTSEMWAIT_FLAGS_INDEFINITE; 85 else 86 pWait->iTimeout = (int)cTicks; 87 #endif 88 89 return 0; 90 } 91 92 /** 67 93 * Initializes a wait. 68 94 * … … 80 106 { 81 107 pWait->iTimeout = 0; 108 pWait->uNsAbsTimeout = 0; /* shut up gcc */ 82 109 83 110 /* … … 104 131 if (u64Now + uTimeout < u64Now) /* overflow */ 105 132 fFlags |= RTSEMWAIT_FLAGS_INDEFINITE; 133 else 134 pWait->uNsAbsTimeout = u64Now + uTimeout; 106 135 } 107 136 else … … 111 140 return VERR_TIMEOUT; 112 141 142 pWait->uNsAbsTimeout = uTimeout; 113 143 uTimeout -= u64Now; /* Get a relative value. */ 114 144 } … … 119 149 { 120 150 pWait->fIndefinite = false; 121 122 #if 0 123 struct timeval tv; 124 125 tv.tv_sec = uTimeout / UINT64_C(1000000000); 126 tv.tv_usec = (uTimeout % UINT64_C(1000000000)) / UINT64_C(1000); 127 128 pWait->iTimeout = tvtohz(&tv); 129 #else 130 uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000)); 131 if (cTicks >= INT_MAX) 132 fFlags |= RTSEMWAIT_FLAGS_INDEFINITE; 133 else 134 pWait->iTimeout = (int)cTicks; 135 #endif 151 fFlags |= rtR0SemBsdWaitUpdateTimeout(pWait, uTimeout); 136 152 } 137 153 … … 140 156 pWait->fIndefinite = true; 141 157 pWait->iTimeout = INT_MAX; 158 pWait->uNsAbsTimeout = UINT64_MAX; 142 159 } 143 160 … … 208 225 case 0: 209 226 break; 227 case ERESTART: 228 { 229 if (!pWait->fIndefinite) 230 { 231 /* Recalc timeout. */ 232 uint64_t u64Now = RTTimeSystemNanoTS(); 233 if (u64Now >= pWait->uNsAbsTimeout) 234 pWait->fTimedOut = true; 235 else 236 { 237 u64Now = pWait->uNsAbsTimeout - u64Now; 238 rtR0SemBsdWaitUpdateTimeout(pWait, u64Now); 239 } 240 } 241 break; 242 } 210 243 case EWOULDBLOCK: 211 244 pWait->fTimedOut = true; 212 245 break; 213 246 case EINTR: 214 case ERESTART:247 Assert(pWait->fInterruptible); 215 248 pWait->fInterrupted = true; 216 249 break;
Note:
See TracChangeset
for help on using the changeset viewer.