Changeset 22952 in vbox
- Timestamp:
- Sep 11, 2009 12:00:48 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
r22950 r22952 197 197 */ 198 198 struct timespec ts; 199 struct timespec tsEnd; 199 200 struct timespec *pTimeout = NULL; 200 if ( cMillies != RT_INDEFINITE_WAIT)201 if (RT_UNLIKELY(cMillies != RT_INDEFINITE_WAIT)) 201 202 { 202 203 ts.tv_sec = cMillies / 1000; 203 204 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 } 204 213 pTimeout = &ts; 205 214 } … … 246 255 break; 247 256 } 257 /* adjust the relative timeout */ 258 if (RT_UNLIKELY(pTimeout)) 259 { 260 clock_gettime(CLOCK_REALTIME, &ts); 261 ts.tv_nsec = tsEnd.tv_nsec - ts.tv_nsec; 262 ts.tv_sec = tsEnd.tv_nsec - 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_nsec--; 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)) 272 { 273 rc = VERR_TIMEOUT; 274 break; 275 } 276 } 248 277 } 249 278 -
trunk/src/VBox/Runtime/r3/linux/semeventmulti-linux.cpp
r14468 r22952 218 218 */ 219 219 struct timespec ts; 220 struct timespec tsEnd; 220 221 struct timespec *pTimeout = NULL; 221 if ( cMillies != RT_INDEFINITE_WAIT)222 if (RT_UNLIKELY(cMillies != RT_INDEFINITE_WAIT)) 222 223 { 223 224 ts.tv_sec = cMillies / 1000; 224 225 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 } 225 234 pTimeout = &ts; 226 235 } … … 240 249 || ASMAtomicCmpXchgS32(&pThis->iState, 1, 0)) 241 250 { 251 /* adjust the relative timeout */ 252 if (RT_UNLIKELY(pTimeout)) 253 { 254 clock_gettime(CLOCK_REALTIME, &ts); 255 ts.tv_nsec = tsEnd.tv_nsec - ts.tv_nsec; 256 ts.tv_sec = tsEnd.tv_nsec - 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_nsec--; 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)) 266 return VERR_TIMEOUT; 267 } 242 268 long rc = sys_futex(&pThis->iState, FUTEX_WAIT, 1, pTimeout, NULL, 0); 243 269 if (RT_UNLIKELY(pThis->iMagic != RTSEMEVENTMULTI_MAGIC))
Note:
See TracChangeset
for help on using the changeset viewer.