VirtualBox

Ignore:
Timestamp:
May 7, 2008 11:01:00 AM (17 years ago)
Author:
vboxsync
Message:

Added lock counts to the threads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r8245 r8645  
    199199#ifdef IN_RING3
    200200
    201 inline void rtThreadLockRW(void)
     201DECLINLINE(void) rtThreadLockRW(void)
    202202{
    203203    if (g_ThreadRWSem == NIL_RTSEMRW)
     
    208208
    209209
    210 inline void rtThreadLockRD(void)
     210DECLINLINE(void) rtThreadLockRD(void)
    211211{
    212212    if (g_ThreadRWSem == NIL_RTSEMRW)
     
    217217
    218218
    219 inline void rtThreadUnLockRW(void)
     219DECLINLINE(void) rtThreadUnLockRW(void)
    220220{
    221221    int rc = RTSemRWReleaseWrite(g_ThreadRWSem);
     
    224224
    225225
    226 inline void rtThreadUnLockRD(void)
     226DECLINLINE(void) rtThreadUnLockRD(void)
    227227{
    228228    int rc = RTSemRWReleaseRead(g_ThreadRWSem);
     
    244244    /*
    245245     * Allocate and insert the thread.
     246     * (It is vital that rtThreadNativeAdopt updates the TLS before
     247     * we try inserting the thread because of locking.)
    246248     */
    247249    int rc = VERR_NO_MEMORY;
     
    10541056
    10551057/**
     1058 * Gets the number of write locks and critical sections the specified
     1059 * thread owns.
     1060 *
     1061 * This number does not include any nested lock/critect entries.
     1062 *
     1063 * Note that it probably will return 0 for non-strict builds since
     1064 * release builds doesn't do unnecessary diagnostic counting like this.
     1065 *
     1066 * @returns Number of locks on success (0+) and VERR_INVALID_HANDLER on failure
     1067 * @param   Thread          The thread we're inquiring about.
     1068 */
     1069RTDECL(int32_t) RTThreadGetWriteLockCount(RTTHREAD Thread)
     1070{
     1071    PRTTHREADINT pThread = rtThreadGet(Thread);
     1072    if (!pThread)
     1073        return VERR_INVALID_HANDLE;
     1074    int32_t cWriteLocks = ASMAtomicReadS32(&pThread->cWriteLocks);
     1075    rtThreadRelease(pThread);
     1076    return cWriteLocks;
     1077}
     1078
     1079
     1080/**
     1081 * Works the THREADINT::cWriteLocks member, mostly internal.
     1082 *
     1083 * @param   Thread      The current thread.
     1084 */
     1085RTDECL(void) RTThreadWriteLockInc(RTTHREAD Thread)
     1086{
     1087    PRTTHREADINT pThread = rtThreadGet(Thread);
     1088    Assert(pThread);
     1089    ASMAtomicIncS32(&pThread->cWriteLocks);
     1090    rtThreadRelease(pThread);
     1091}
     1092
     1093
     1094/**
     1095 * Works the THREADINT::cWriteLocks member, mostly internal.
     1096 *
     1097 * @param   Thread      The current thread.
     1098 */
     1099RTDECL(void) RTThreadWriteLockDec(RTTHREAD Thread)
     1100{
     1101    PRTTHREADINT pThread = rtThreadGet(Thread);
     1102    Assert(pThread);
     1103    ASMAtomicDecS32(&pThread->cWriteLocks);
     1104    rtThreadRelease(pThread);
     1105}
     1106
     1107
     1108/**
     1109 * Gets the number of read locks the specified thread owns.
     1110 *
     1111 * Note that nesting read lock entry will be included in the
     1112 * total sum. And that it probably will return 0 for non-strict
     1113 * builds since release builds doesn't do unnecessary diagnostic
     1114 * counting like this.
     1115 *
     1116 * @returns Number of read locks on success (0+) and VERR_INVALID_HANDLER on failure
     1117 * @param   Thread          The thread we're inquiring about.
     1118 */
     1119RTDECL(int32_t) RTThreadGetReadLockCount(RTTHREAD Thread)
     1120{
     1121    PRTTHREADINT pThread = rtThreadGet(Thread);
     1122    if (!pThread)
     1123        return VERR_INVALID_HANDLE;
     1124    int32_t cReadLocks = ASMAtomicReadS32(&pThread->cReadLocks);
     1125    rtThreadRelease(pThread);
     1126    return cReadLocks;
     1127}
     1128
     1129
     1130/**
     1131 * Works the THREADINT::cReadLocks member.
     1132 *
     1133 * @param   Thread      The current thread.
     1134 */
     1135RTDECL(void) RTThreadReadLockInc(RTTHREAD Thread)
     1136{
     1137    PRTTHREADINT pThread = rtThreadGet(Thread);
     1138    Assert(pThread);
     1139    ASMAtomicIncS32(&pThread->cReadLocks);
     1140    rtThreadRelease(pThread);
     1141}
     1142
     1143
     1144/**
     1145 * Works the THREADINT::cReadLocks member.
     1146 *
     1147 * @param   Thread      The current thread.
     1148 */
     1149RTDECL(void) RTThreadReadLockDec(RTTHREAD Thread)
     1150{
     1151    PRTTHREADINT pThread = rtThreadGet(Thread);
     1152    Assert(pThread);
     1153    ASMAtomicDecS32(&pThread->cReadLocks);
     1154    rtThreadRelease(pThread);
     1155}
     1156
     1157
     1158
     1159
     1160
     1161/**
    10561162 * Recalculates scheduling attributes for the the default process
    10571163 * priority using the specified priority type for the calling thread.
     
    10621168 *
    10631169 * @returns iprt status code.
     1170 * @remarks Will only work for strict builds.
    10641171 */
    10651172int rtThreadDoCalcDefaultPriority(RTTHREADTYPE enmType)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette