Changeset 8645 in vbox for trunk/src/VBox/Runtime/common/misc
- Timestamp:
- May 7, 2008 11:01:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/thread.cpp
r8245 r8645 199 199 #ifdef IN_RING3 200 200 201 inline voidrtThreadLockRW(void)201 DECLINLINE(void) rtThreadLockRW(void) 202 202 { 203 203 if (g_ThreadRWSem == NIL_RTSEMRW) … … 208 208 209 209 210 inline voidrtThreadLockRD(void)210 DECLINLINE(void) rtThreadLockRD(void) 211 211 { 212 212 if (g_ThreadRWSem == NIL_RTSEMRW) … … 217 217 218 218 219 inline voidrtThreadUnLockRW(void)219 DECLINLINE(void) rtThreadUnLockRW(void) 220 220 { 221 221 int rc = RTSemRWReleaseWrite(g_ThreadRWSem); … … 224 224 225 225 226 inline voidrtThreadUnLockRD(void)226 DECLINLINE(void) rtThreadUnLockRD(void) 227 227 { 228 228 int rc = RTSemRWReleaseRead(g_ThreadRWSem); … … 244 244 /* 245 245 * Allocate and insert the thread. 246 * (It is vital that rtThreadNativeAdopt updates the TLS before 247 * we try inserting the thread because of locking.) 246 248 */ 247 249 int rc = VERR_NO_MEMORY; … … 1054 1056 1055 1057 /** 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 */ 1069 RTDECL(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 */ 1085 RTDECL(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 */ 1099 RTDECL(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 */ 1119 RTDECL(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 */ 1135 RTDECL(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 */ 1149 RTDECL(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 /** 1056 1162 * Recalculates scheduling attributes for the the default process 1057 1163 * priority using the specified priority type for the calling thread. … … 1062 1168 * 1063 1169 * @returns iprt status code. 1170 * @remarks Will only work for strict builds. 1064 1171 */ 1065 1172 int rtThreadDoCalcDefaultPriority(RTTHREADTYPE enmType)
Note:
See TracChangeset
for help on using the changeset viewer.