Changeset 25620 in vbox
- Timestamp:
- Jan 2, 2010 10:18:07 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
include/iprt/semaphore.h (modified) (2 diffs)
-
src/VBox/Runtime/generic/semrw-generic.cpp (modified) (7 diffs)
-
src/VBox/Runtime/r3/posix/semrw-posix.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/semaphore.h
r25616 r25620 491 491 */ 492 492 RTDECL(int) RTSemRWRequestReadNoResume(RTSEMRW RWSem, unsigned cMillies); 493 494 /** 495 * Debug version of RTSemRWRequestRead that tracks the location. 496 * 497 * @returns iprt status code. 498 * @retval VINF_SUCCESS on success. 499 * @retval VERR_INTERRUPT if the wait was interrupted. 500 * @retval VERR_INVALID_HANDLE if RWSem is invalid. 501 * 502 * @param RWSem The Read/Write semaphore to request read access to. 503 * @param cMillies The number of milliseconds to wait. 504 * @param uId Some kind of locking location ID. Typically a 505 * return address up the stack. Optional (0). 506 * @param pszFile The file where the lock is being acquired from. 507 * Optional. 508 * @param iLine The line number in that file. Optional (0). 509 * @param pszFunction The functionn where the lock is being acquired 510 * from. Optional. 511 */ 512 RTDECL(int) RTSemRWRequestReadDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL); 513 514 /** 515 * Debug version of RTSemRWRequestWriteNoResume that tracks the location. 516 * 517 * @returns iprt status code. 518 * @retval VINF_SUCCESS on success. 519 * @retval VERR_INTERRUPT if the wait was interrupted. 520 * @retval VERR_INVALID_HANDLE if RWSem is invalid. 521 * 522 * @param RWSem The Read/Write semaphore to request read access to. 523 * @param cMillies The number of milliseconds to wait. 524 * @param uId Some kind of locking location ID. Typically a 525 * return address up the stack. Optional (0). 526 * @param pszFile The file where the lock is being acquired from. 527 * Optional. 528 * @param iLine The line number in that file. Optional (0). 529 * @param pszFunction The functionn where the lock is being acquired 530 * from. Optional. 531 */ 532 RTDECL(int) RTSemRWRequestReadNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL); 493 533 494 534 /** … … 605 645 */ 606 646 RTDECL(uint32_t) RTSemRWGetReadCount(RTSEMRW RWSem); 647 648 /* Strict build: Remap the four request calls to the debug versions. */ 649 #ifdef RT_STRICT 650 # ifdef ___iprt_asm_h 651 # define RTSemRWRequestRead(pCritSect, cMillies) RTSemRWRequestReadDebug((pCritSect), (cMillies), (uintptr_t)ASMReturnAddress(), RT_SRC_POS) 652 # define RTSemRWRequestReadNoResume(pCritSect, cMillies) RTSemRWRequestReadNoResumeDebug((pCritSect), (cMillies), (uintptr_t)ASMReturnAddress(), RT_SRC_POS) 653 # define RTSemRWRequestWrite(pCritSect, cMillies) RTSemRWRequestWriteDebug((pCritSect), (cMillies), (uintptr_t)ASMReturnAddress(), RT_SRC_POS) 654 # define RTSemRWRequestWriteNoResume(pCritSect, cMillies) RTSemRWRequestWriteNoResumeDebug((pCritSect), (cMillies), (uintptr_t)ASMReturnAddress(), RT_SRC_POS) 655 # else 656 # define RTSemRWRequestRead(pCritSect, cMillies) RTSemRWRequestReadDebug((pCritSect), (cMillies), 0, RT_SRC_POS) 657 # define RTSemRWRequestReadNoResume(pCritSect, cMillies) RTSemRWRequestReadNoResumeDebug((pCritSect), (cMillies), 0, RT_SRC_POS) 658 # define RTSemRWRequestWrite(pCritSect, cMillies) RTSemRWRequestWriteDebug((pCritSect), (cMillies), 0, RT_SRC_POS) 659 # define RTSemRWRequestWriteNoResume(pCritSect, cMillies) RTSemRWRequestWriteNoResumeDebug((pCritSect), (cMillies), 0, RT_SRC_POS) 660 # endif 661 #endif 607 662 608 663 /** @} */ -
trunk/src/VBox/Runtime/generic/semrw-generic.cpp
r25618 r25620 91 91 92 92 93 /* No debug wrapping here. */ 94 #undef RTSemRWRequestRead 95 #undef RTSemRWRequestReadNoResume 96 #undef RTSemRWRequestWrite 97 #undef RTSemRWRequestWriteNoResume 98 93 99 94 100 RTDECL(int) RTSemRWCreate(PRTSEMRW pRWSem) … … 217 223 218 224 219 RTDECL(int) RTSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies) 220 { 221 PRTLOCKVALSRCPOS pSrcPos = NULL; 222 225 DECL_FORCE_INLINE(int) rtSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies, bool fInterruptible, PCRTLOCKVALSRCPOS pSrcPos) 226 { 223 227 /* 224 228 * Validate handle. … … 326 330 RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_READ); 327 331 #endif 328 int rcWait = rc = RTSemEventMultiWait(pThis->ReadEvent, cMillies); 332 int rcWait; 333 if (fInterruptible) 334 rcWait = rc = RTSemEventMultiWaitNoResume(pThis->ReadEvent, cMillies); 335 else 336 rcWait = rc = RTSemEventMultiWait(pThis->ReadEvent, cMillies); 329 337 RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_RW_READ); 330 338 if (RT_FAILURE(rc) && rc != VERR_TIMEOUT) /* handle timeout below */ … … 382 390 return rc; 383 391 } 392 393 394 RTDECL(int) RTSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies) 395 { 396 #ifndef RTSEMRW_STRICT 397 return rtSemRWRequestRead(RWSem, cMillies, false, NULL); 398 #else 399 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API(); 400 return rtSemRWRequestRead(RWSem, cMillies, false, &SrcPos); 401 #endif 402 } 384 403 RT_EXPORT_SYMBOL(RTSemRWRequestRead); 385 404 386 405 406 RTDECL(int) RTSemRWRequestReadDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL) 407 { 408 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API(); 409 return rtSemRWRequestRead(RWSem, cMillies, false, &SrcPos); 410 } 411 RT_EXPORT_SYMBOL(RTSemRWRequestReadDebug); 412 413 387 414 RTDECL(int) RTSemRWRequestReadNoResume(RTSEMRW RWSem, unsigned cMillies) 388 415 { 389 return RTSemRWRequestRead(RWSem, cMillies); 416 #ifndef RTSEMRW_STRICT 417 return rtSemRWRequestRead(RWSem, cMillies, true, NULL); 418 #else 419 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API(); 420 return rtSemRWRequestRead(RWSem, cMillies, true, &SrcPos); 421 #endif 390 422 } 391 423 RT_EXPORT_SYMBOL(RTSemRWRequestReadNoResume); 424 425 426 RTDECL(int) RTSemRWRequestReadNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL) 427 { 428 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API(); 429 return rtSemRWRequestRead(RWSem, cMillies, true, &SrcPos); 430 } 431 RT_EXPORT_SYMBOL(RTSemRWRequestReadNoResumeDebug); 392 432 393 433 … … 472 512 473 513 474 RTDECL(int) RTSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies) 475 { 476 PRTLOCKVALSRCPOS pSrcPos = NULL; 477 514 DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies, bool fInterruptible, PCRTLOCKVALSRCPOS pSrcPos) 515 { 478 516 /* 479 517 * Validate handle. … … 580 618 RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_WRITE); 581 619 #endif 582 int rcWait = rc = RTSemEventWait(pThis->WriteEvent, cMillies); 620 int rcWait; 621 if (fInterruptible) 622 rcWait = rc = RTSemEventWaitNoResume(pThis->WriteEvent, cMillies); 623 else 624 rcWait = rc = RTSemEventWait(pThis->WriteEvent, cMillies); 583 625 RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_RW_WRITE); 584 626 if (RT_UNLIKELY(RT_FAILURE_NP(rc) && rc != VERR_TIMEOUT)) /* timeouts are handled below */ … … 651 693 return rc; 652 694 } 695 696 697 RTDECL(int) RTSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies) 698 { 699 #ifndef RTSEMRW_STRICT 700 return rtSemRWRequestWrite(RWSem, cMillies, false, NULL); 701 #else 702 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API(); 703 return rtSemRWRequestWrite(RWSem, cMillies, false, &SrcPos); 704 #endif 705 } 653 706 RT_EXPORT_SYMBOL(RTSemRWRequestWrite); 654 707 655 708 709 RTDECL(int) RTSemRWRequestWriteDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL) 710 { 711 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API(); 712 return rtSemRWRequestWrite(RWSem, cMillies, false, &SrcPos); 713 } 714 RT_EXPORT_SYMBOL(RTSemRWRequestWriteDebug); 715 716 656 717 RTDECL(int) RTSemRWRequestWriteNoResume(RTSEMRW RWSem, unsigned cMillies) 657 718 { 658 return RTSemRWRequestWrite(RWSem, cMillies); 719 #ifndef RTSEMRW_STRICT 720 return rtSemRWRequestWrite(RWSem, cMillies, true, NULL); 721 #else 722 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API(); 723 return rtSemRWRequestWrite(RWSem, cMillies, true, &SrcPos); 724 #endif 659 725 } 660 726 RT_EXPORT_SYMBOL(RTSemRWRequestWriteNoResume); 727 728 729 RTDECL(int) RTSemRWRequestWriteNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL) 730 { 731 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API(); 732 return rtSemRWRequestWrite(RWSem, cMillies, true, &SrcPos); 733 } 734 RT_EXPORT_SYMBOL(RTSemRWRequestWriteNoResumeDebug); 661 735 662 736 -
trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp
r25618 r25620 93 93 94 94 95 /* No debug wrapping here. */ 96 #undef RTSemRWRequestRead 97 #undef RTSemRWRequestReadNoResume 98 #undef RTSemRWRequestWrite 99 #undef RTSemRWRequestWriteNoResume 100 101 95 102 RTDECL(int) RTSemRWCreate(PRTSEMRW pRWSem) 96 103 { … … 180 187 181 188 182 RTDECL(int) RTSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies) 183 { 184 PRTLOCKVALSRCPOS pSrcPos = NULL; 185 189 DECL_FORCE_INLINE(int) rtSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies, PCRTLOCKVALSRCPOS pSrcPos) 190 { 186 191 /* 187 192 * Validate input. … … 281 286 282 287 288 RTDECL(int) RTSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies) 289 { 290 #ifndef RTSEMRW_STRICT 291 return rtSemRWRequestRead(RWSem, cMillies, NULL); 292 #else 293 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API(); 294 return rtSemRWRequestRead(RWSem, cMillies, &SrcPos); 295 #endif 296 } 297 298 299 RTDECL(int) RTSemRWRequestReadDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL) 300 { 301 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API(); 302 return rtSemRWRequestRead(RWSem, cMillies, &SrcPos); 303 } 304 305 283 306 RTDECL(int) RTSemRWRequestReadNoResume(RTSEMRW RWSem, unsigned cMillies) 284 307 { 285 308 /* EINTR isn't returned by the wait functions we're using. */ 286 return RTSemRWRequestRead(RWSem, cMillies); 309 #ifndef RTSEMRW_STRICT 310 return rtSemRWRequestRead(RWSem, cMillies, NULL); 311 #else 312 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API(); 313 return rtSemRWRequestRead(RWSem, cMillies, &SrcPos); 314 #endif 315 } 316 317 318 RTDECL(int) RTSemRWRequestReadNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL) 319 { 320 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API(); 321 return rtSemRWRequestRead(RWSem, cMillies, &SrcPos); 287 322 } 288 323
Note:
See TracChangeset
for help on using the changeset viewer.

