Changeset 22956 in vbox
- Timestamp:
- Sep 11, 2009 12:55:18 PM (15 years ago)
- Location:
- trunk/src/VBox/Runtime/r3/linux
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/linux/semevent-linux.cpp
r22955 r22956 54 54 #include <iprt/asm.h> 55 55 #include <iprt/err.h> 56 #include <iprt/time.h> 56 57 #include "internal/magics.h" 57 58 … … 197 198 */ 198 199 struct timespec ts; 199 struct timespec tsEnd;200 200 struct timespec *pTimeout = NULL; 201 uint64_t u64End = 0; /* shut up gcc */ 201 202 if (cMillies != RT_INDEFINITE_WAIT) 202 203 { 203 204 ts.tv_sec = cMillies / 1000; 204 205 ts.tv_nsec = (cMillies % 1000) * 1000000; 205 clock_gettime(CLOCK_REALTIME, &tsEnd); 206 tsEnd.tv_sec += ts.tv_sec; 207 tsEnd.tv_nsec += ts.tv_nsec; 208 if (tsEnd.tv_nsec >= 1000000000) 209 { 210 tsEnd.tv_nsec -= 1000000000; 211 tsEnd.tv_sec++; 212 } 206 u64End = RTTimeSystemNanoTS() + cMillies * 1000000; 213 207 pTimeout = &ts; 214 208 } … … 258 252 if (pTimeout) 259 253 { 260 clock_gettime(CLOCK_REALTIME, &ts); 261 ts.tv_nsec = tsEnd.tv_nsec - ts.tv_nsec; 262 ts.tv_sec = tsEnd.tv_sec - ts.tv_sec; 263 if (ts.tv_nsec < 0) 264 { 265 ts.tv_nsec += 1000000000; /* not correct if ts.tv_sec is negative but we 266 leave on negative timeouts in any case */ 267 ts.tv_sec--; 268 } 269 /* don't wait for less than 1 microsecond */ 270 if ( ts.tv_sec < 0 271 || (ts.tv_sec == 0 && ts.tv_nsec < 1000)) 254 int64_t u64Diff = u64End - RTTimeSystemNanoTS(); 255 if (u64Diff < 1000) 272 256 { 273 257 rc = VERR_TIMEOUT; 274 258 break; 275 259 } 260 ts.tv_sec = u64Diff / 1000000000; 261 ts.tv_nsec = u64Diff % 1000000000; 276 262 } 277 263 } -
trunk/src/VBox/Runtime/r3/linux/semeventmulti-linux.cpp
r22955 r22956 56 56 #include <iprt/asm.h> 57 57 #include <iprt/err.h> 58 #include <iprt/time.h> 58 59 #include "internal/magics.h" 59 60 … … 218 219 */ 219 220 struct timespec ts; 220 struct timespec tsEnd;221 221 struct timespec *pTimeout = NULL; 222 uint64_t u64End = 0; /* shut up gcc */ 222 223 if (cMillies != RT_INDEFINITE_WAIT) 223 224 { 224 225 ts.tv_sec = cMillies / 1000; 225 226 ts.tv_nsec = (cMillies % 1000) * 1000000; 226 clock_gettime(CLOCK_REALTIME, &tsEnd); 227 tsEnd.tv_sec += ts.tv_sec; 228 tsEnd.tv_nsec += ts.tv_nsec; 229 if (tsEnd.tv_nsec >= 1000000000) 230 { 231 tsEnd.tv_nsec -= 1000000000; 232 tsEnd.tv_sec++; 233 } 227 u64End = RTTimeSystemNanoTS() + cMillies * 1000000; 234 228 pTimeout = &ts; 235 229 } … … 252 246 if (pTimeout) 253 247 { 254 clock_gettime(CLOCK_REALTIME, &ts); 255 ts.tv_nsec = tsEnd.tv_nsec - ts.tv_nsec; 256 ts.tv_sec = tsEnd.tv_sec - ts.tv_sec; 257 if (ts.tv_nsec < 0) 258 { 259 ts.tv_nsec += 1000000000; /* not correct if ts.tv_sec is negative but we 260 leave on negative timeouts in any case */ 261 ts.tv_sec--; 262 } 263 /* don't wait for less than 1 microsecond */ 264 if ( ts.tv_sec < 0 265 || (ts.tv_sec == 0 && ts.tv_nsec < 1000)) 248 int64_t u64Diff = u64End - RTTimeSystemNanoTS(); 249 if (u64Diff < 1000) 266 250 return VERR_TIMEOUT; 251 ts.tv_sec = u64Diff / 1000000000; 252 ts.tv_nsec = u64Diff % 1000000000; 267 253 } 268 254 long rc = sys_futex(&pThis->iState, FUTEX_WAIT, 1, pTimeout, NULL, 0);
Note:
See TracChangeset
for help on using the changeset viewer.